Skip to content

Commit 19c44a0

Browse files
sekatiJason Horwitz
authored andcommitted
Merge branch 'master' of git://github.com/philsturgeon/codeigniter-restserver
2 parents 03a3d31 + 8dca4b3 commit 19c44a0

File tree

15 files changed

+362
-139
lines changed

15 files changed

+362
-139
lines changed

README.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
A fully RESTful server implementation for CodeIgniter using one library, one
44
config file and one controller.
55

6-
## Sponsored by: Coding Futures
7-
86
## Requirements
97

10-
1. PHP 5.2+
8+
1. PHP 5.2 or greater
119
2. CodeIgniter 2.1.0 to 3.0-dev
1210

1311
_Note: for 1.7.x support download v2.2 from Downloads tab_
@@ -53,7 +51,7 @@ This means your URLs can look like this:
5351
http://example.com/books.json
5452
http://example.com/books?format=json
5553

56-
Alternatively (and recommend) is using the HTTP `Accept` header, which is built for this purpose:
54+
This can be flaky with URI segments, so the recommend approach is using the HTTP `Accept` header:
5755

5856
$ curl -H "Accept: application/json" http://example.com
5957

@@ -85,19 +83,19 @@ If you don't specify a response code, and the data you respond with `== FALSE` (
8583

8684
## Multilingual Support
8785

88-
If your application uses language files to support multiple locales, `REST_Controller` will automatically parse the HTTP `Accept-Language` header and provide the language(s) in your actions. This information can be found in the `$this->request->lang` object:
86+
If your application uses language files to support multiple locales, `REST_Controller` will automatically parse the HTTP `Accept-Language` header and provide the language(s) in your actions. This information can be found in the `$this->response->lang` object:
8987

9088
public function __construct()
9189
{
9290
parent::__construct();
9391

94-
if (is_array($this->request->lang))
92+
if (is_array($this->response->lang))
9593
{
96-
$this->load->language('application', $this->request->lang[0]);
94+
$this->load->language('application', $this->response->lang[0]);
9795
}
9896
else
9997
{
100-
$this->load->language('application', $this->request->lang);
98+
$this->load->language('application', $this->response->lang);
10199
}
102100
}
103101

@@ -148,11 +146,27 @@ By default, the HTTP will be `X-API-KEY`. This can be configured in **config/res
148146

149147
## Change Log
150148

149+
### 2.6.2
150+
151+
* Update CodeIgniter files to 2.1.3
152+
* Fixed issue #165
153+
154+
### 2.6.1
155+
156+
* Update CodeIgniter files to 2.1.2
157+
* Log Table support for IPv6 & NULL parameters
158+
* Abstract out the processes of firing a controller method within _remap() to an separate method
159+
* Moved GET, POST, PUT, and DELETE parsing to separate methods, allowing them to be overridden as needed
160+
* Small bugfix for a PHP 5.3 strlen error
161+
* Fixed some PHP 5.4 warnings
162+
* Fix for bug in Format.php's to_html() which failed to detect if $data was really a multidimensional array.
163+
* Fix for empty node on XML output format, for false = 0, true = 1.
164+
151165
### 2.6.0
152166

153167
* Added loads of PHPDoc comments.
154168
* Response where method doesn't exist is now "HTTP 405 Method Not Allowed", not "HTTP 404 Not Found".
155-
* Compatable with PHP 5.4.
169+
* Compatible with PHP 5.4.
156170
* Added support for gzip compression.
157171
* Fix the apache\_request\_header function with CGI.
158172
* Fixed up correctly .foo extensions to work when get arguments provided.
@@ -198,7 +212,12 @@ By default, the HTTP will be `X-API-KEY`. This can be configured in **config/res
198212
* key => FALSE can now be used to override the keys_enabled option for a specific method, and level is now optional. If no level is set it will assume the method has a level of 0.
199213
* Fixed issue where calls to ->get('foo') would error is foo was not set. Reported by Paul Barto.
200214

201-
## Donations
215+
## Contributions
216+
217+
This project has been funded and made possible through my clients kindly allowing me to
218+
open-source the functionality as I build it into their projects. I am no longer actively developing
219+
features for this as I no longer require it, but I will continue to maintain pull requests and try to
220+
fix issues as and when they are reported (within a week or two).
202221

203-
If my REST Server has helped you out, or you'd like me to do some custom work on it, [please sponsor me](http://pledgie.com/campaigns/8328)
204-
so I can keep working on this and other CodeIgniter projects for you all.
222+
Pull Requests are the best way to fix bugs or add features. I know loads of you use this, so please
223+
contribute if you have improvements to be made and I'll keep releasing versions over time.

application/config/ldap.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$config['binduser'] = 'cn=Authentication,ou=Services,dc=example,dc=org';
4+
$config['basedn'] = 'dc=example,dc=org';
5+
$config['bindpw'] = 'E984asdy2';
6+
7+
/*
8+
* The host name parameter can be a space separated list of host names.
9+
* This means that the LDAP code will talk to a backup server if the main server is not operational.
10+
* There will be a delay while the code times out trying to talk to the main server but things will still work.
11+
*/
12+
13+
$config['server'] = 'ldapserver1.example.org ldapserver2.example.org';
14+
$config['port'] = NULL;
15+
16+
/*
17+
* Controls the LDAP_OPT_NETWORK_TIMEOUT option, this is how long the code will attempt to talk to the primary server if it is unreachable.
18+
*/
19+
20+
$config['timeout'] = 5;
21+
?>

application/config/rest.php

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php defined('BASEPATH') OR exit('No direct script access allowed');
22

3+
/*
4+
|--------------------------------------------------------------------------
5+
| HTTP protocol
6+
|--------------------------------------------------------------------------
7+
|
8+
| Should the service accept only HTTPS requests or not?
9+
|
10+
| Default: FALSE
11+
|
12+
*/
13+
$config['force_https'] = FALSE;
14+
315
/*
416
|--------------------------------------------------------------------------
517
| REST Format
@@ -49,6 +61,18 @@
4961
*/
5062
$config['rest_auth'] = false;
5163

64+
/*
65+
|--------------------------------------------------------------------------
66+
| REST Login
67+
|--------------------------------------------------------------------------
68+
|
69+
| Is login required and if so, which user store do we use?
70+
|
71+
| '' = use config based users, 'ldap' = use LDAP authencation
72+
|
73+
*/
74+
$config['auth_source'] = 'ldap';
75+
5276
/*
5377
|--------------------------------------------------------------------------
5478
| Override auth types for specific class/method
@@ -77,7 +101,7 @@
77101
| REST Login usernames
78102
|--------------------------------------------------------------------------
79103
|
80-
| Array of usernames and passwords for login
104+
| Array of usernames and passwords for login, if ldap is configured this is ignored
81105
|
82106
| array('admin' => '1234')
83107
|
@@ -156,13 +180,26 @@
156180
`key` varchar(40) NOT NULL,
157181
`level` int(2) NOT NULL,
158182
`ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
183+
`is_private_key` tinyint(1) NOT NULL DEFAULT '0',
184+
`ip_addresses` TEXT NULL DEFAULT NULL,
159185
`date_created` int(11) NOT NULL,
160186
PRIMARY KEY (`id`)
161187
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
162188
|
163189
*/
164190
$config['rest_enable_keys'] = FALSE;
165191

192+
/*
193+
|--------------------------------------------------------------------------
194+
| REST Table Key Column Name
195+
|--------------------------------------------------------------------------
196+
|
197+
| If you are not using the default table schema as shown above, what is the
198+
| name of the db column that holds the api key value?
199+
|
200+
*/
201+
$config['rest_key_column'] = 'key';
202+
166203
/*
167204
|--------------------------------------------------------------------------
168205
| REST Key Length
@@ -290,4 +327,4 @@
290327
$config['rest_ajax_only'] = FALSE;
291328

292329
/* End of file config.php */
293-
/* Location: ./system/application/config/rest.php */
330+
/* Location: ./system/application/config/rest.php */

0 commit comments

Comments
 (0)