Class REST_Controller
CodeIgniter Rest Controller A fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.
- CI_Controller
- REST_Controller
Package: CodeIgniter\Libraries
Category: Libraries
License: MIT
Author: Phil Sturgeon, Chris Kacerguis
Version: 3.0.0
Link: https://github.com/chriskacerguis/codeigniter-restserver
Located at libraries/REST_Controller.php
protected
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
set_response( array|null $data = NULL, integer|null $http_code = NULL )
Takes mixed data and optionally a status code, then creates the response within the buffers of the Output class. The response is sent to the client lately by the framework, after the current controller's method termination. All the hooks after the controller's method termination are executable |
protected
string|null
|
|
protected
string
|
#
_get_default_output_format( )
Gets the default format from the configuration. Fallbacks to 'json' if the corresponding configuration option $config['rest_default_format'] is missing or is empty |
protected
mixed|null|string
|
|
protected
string|null
|
|
protected
boolean
|
|
protected
string|null
|
|
protected
boolean
|
|
protected
boolean
|
#
_check_limit( string $controller_method )
Check if the requests to a controller method exceed a limit |
protected
boolean
|
#
_auth_override_check( )
Check if there is a specific auth type set for the current class/method/HTTP-method being called |
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
public
array|string|null
|
|
public
array|string|null
|
|
public
array|string|null
|
|
public
array|string|null
|
|
public
array|string|null
|
|
public
array|string|null
|
|
public
array|string|null
|
|
public
array|string|null
|
|
protected
string
|
#
_xss_clean( string $value, boolean $xss_clean )
Sanitizes data so that Cross Site Scripting Hacks can be prevented |
public
array
|
|
protected
boolean
|
|
protected
boolean
|
#
_perform_library_auth( string $username = '', string $password = NULL )
Perform Library Authentication - Override this function to change the way the library is called |
protected
boolean
|
#
_check_login( string $username = NULL, boolean|string $password = FALSE )
Check if the user is logged in |
protected
|
|
protected
|
|
protected
|
|
protected
|
#
_check_blacklist_auth( )
Checks if the client's ip is in the 'rest_ip_blacklist' config and generates a 401 response |
protected
|
#
_check_whitelist_auth( )
Check if the client's ip is in the 'rest_ip_whitelist' config and generates a 401 response |
protected
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
boolean
|
|
protected
|
#
_check_cors( )
Checks allowed domains, and adds appropriate headers for HTTP access control (CORS) |
integer |
HTTP_CONTINUE
|
#
100
|
integer |
HTTP_SWITCHING_PROTOCOLS
|
#
101
|
integer |
HTTP_PROCESSING
|
#
102
|
integer |
HTTP_OK
The request has succeeded |
#
200
|
integer |
HTTP_CREATED
The server successfully created a new resource |
#
201
|
integer |
HTTP_ACCEPTED
|
#
202
|
integer |
HTTP_NON_AUTHORITATIVE_INFORMATION
|
#
203
|
integer |
HTTP_NO_CONTENT
The server successfully processed the request, though no content is returned |
#
204
|
integer |
HTTP_RESET_CONTENT
|
#
205
|
integer |
HTTP_PARTIAL_CONTENT
|
#
206
|
integer |
HTTP_MULTI_STATUS
|
#
207
|
integer |
HTTP_ALREADY_REPORTED
|
#
208
|
integer |
HTTP_IM_USED
|
#
226
|
integer |
HTTP_MULTIPLE_CHOICES
|
#
300
|
integer |
HTTP_MOVED_PERMANENTLY
|
#
301
|
integer |
HTTP_FOUND
|
#
302
|
integer |
HTTP_SEE_OTHER
|
#
303
|
integer |
HTTP_NOT_MODIFIED
The resource has not been modified since the last request |
#
304
|
integer |
HTTP_USE_PROXY
|
#
305
|
integer |
HTTP_RESERVED
|
#
306
|
integer |
HTTP_TEMPORARY_REDIRECT
|
#
307
|
integer |
HTTP_PERMANENTLY_REDIRECT
|
#
308
|
integer |
HTTP_BAD_REQUEST
The request cannot be fulfilled due to multiple errors |
#
400
|
integer |
HTTP_UNAUTHORIZED
The user is unauthorized to access the requested resource |
#
401
|
integer |
HTTP_PAYMENT_REQUIRED
|
#
402
|
integer |
HTTP_FORBIDDEN
The requested resource is unavailable at this present time |
#
403
|
integer |
HTTP_NOT_FOUND
The requested resource could not be found |
#
404
|
integer |
HTTP_METHOD_NOT_ALLOWED
The request method is not supported by the following resource |
#
405
|
integer |
HTTP_NOT_ACCEPTABLE
The request was not acceptable |
#
406
|
integer |
HTTP_PROXY_AUTHENTICATION_REQUIRED
|
#
407
|
integer |
HTTP_REQUEST_TIMEOUT
|
#
408
|
integer |
HTTP_CONFLICT
The request could not be completed due to a conflict with the current state of the resource |
#
409
|
integer |
HTTP_GONE
|
#
410
|
integer |
HTTP_LENGTH_REQUIRED
|
#
411
|
integer |
HTTP_PRECONDITION_FAILED
|
#
412
|
integer |
HTTP_REQUEST_ENTITY_TOO_LARGE
|
#
413
|
integer |
HTTP_REQUEST_URI_TOO_LONG
|
#
414
|
integer |
HTTP_UNSUPPORTED_MEDIA_TYPE
|
#
415
|
integer |
HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
|
#
416
|
integer |
HTTP_EXPECTATION_FAILED
|
#
417
|
integer |
HTTP_I_AM_A_TEAPOT
|
#
418
|
integer |
HTTP_UNPROCESSABLE_ENTITY
|
#
422
|
integer |
HTTP_LOCKED
|
#
423
|
integer |
HTTP_FAILED_DEPENDENCY
|
#
424
|
integer |
HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL
|
#
425
|
integer |
HTTP_UPGRADE_REQUIRED
|
#
426
|
integer |
HTTP_PRECONDITION_REQUIRED
|
#
428
|
integer |
HTTP_TOO_MANY_REQUESTS
|
#
429
|
integer |
HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
|
#
431
|
integer |
HTTP_INTERNAL_SERVER_ERROR
The server encountered an unexpected error |
#
500
|
integer |
HTTP_NOT_IMPLEMENTED
The server does not recognise the request method |
#
501
|
integer |
HTTP_BAD_GATEWAY
|
#
502
|
integer |
HTTP_SERVICE_UNAVAILABLE
|
#
503
|
integer |
HTTP_GATEWAY_TIMEOUT
|
#
504
|
integer |
HTTP_VERSION_NOT_SUPPORTED
|
#
505
|
integer |
HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL
|
#
506
|
integer |
HTTP_INSUFFICIENT_STORAGE
|
#
507
|
integer |
HTTP_LOOP_DETECTED
|
#
508
|
integer |
HTTP_NOT_EXTENDED
|
#
510
|
integer |
HTTP_NETWORK_AUTHENTICATION_REQUIRED
|
#
511
|
protected
string|null
|
$rest_format
This defines the rest format Must be overridden it in a controller so that it is set |
#
NULL
|
protected
array
|
$methods
Defines the list of method properties such as limit, log and level |
#
[]
|
protected
array
|
$allowed_http_methods
List of allowed HTTP methods |
#
['get', 'delete', 'post', 'put', 'options', 'patch', 'head']
|
protected
object
|
$request
Contains details about the request Fields: body, format, method, ssl Note: This is a dynamic object (stdClass) |
#
NULL
|
protected
object
|
$response
Contains details about the response Fields: format, lang Note: This is a dynamic object (stdClass) |
#
NULL
|
protected
object
|
$rest
Contains details about the REST API Fields: db, ignore_limits, key, level, user_id Note: This is a dynamic object (stdClass) |
#
NULL
|
protected
array
|
$_get_args
The arguments for the GET request method |
#
[]
|
protected
array
|
$_post_args
The arguments for the POST request method |
#
[]
|
protected
array
|
$_put_args
The arguments for the PUT request method |
#
[]
|
protected
array
|
$_delete_args
The arguments for the DELETE request method |
#
[]
|
protected
array
|
$_patch_args
The arguments for the PATCH request method |
#
[]
|
protected
array
|
$_head_args
The arguments for the HEAD request method |
#
[]
|
protected
array
|
$_options_args
The arguments for the OPTIONS request method |
#
[]
|
protected
array
|
$_query_args
The arguments for the query parameters |
#
[]
|
protected
array
|
$_args
The arguments from GET, POST, PUT, DELETE, PATCH, HEAD and OPTIONS request methods combined |
#
[]
|
protected
string
|
$_insert_id
The insert_id of the log entry (if we have one) |
#
''
|
protected
boolean
|
$_allow
If the request is allowed based on the API key provided |
#
TRUE
|
protected
string
|
$_user_ldap_dn
The LDAP Distinguished Name of the User post authentication |
#
''
|
protected
string
|
$_start_rtime
The start of the response time from the server |
#
''
|
protected
string
|
$_end_rtime
The end of the response time from the server |
#
''
|
protected
array
|
$_supported_formats
List all supported methods, the first will be the default format |
#
[
'json' => 'application/json',
'array' => 'application/json',
'csv' => 'application/csv',
'html' => 'text/html',
'jsonp' => 'application/javascript',
'php' => 'text/plain',
'serialized' => 'application/vnd.php.serialized',
'xml' => 'application/xml'
]
|
protected
object
|
$_apiuser
Information about the current API user |
|
protected
boolean
|
$check_cors
Whether or not to perform a CORS check and apply CORS headers to the request |
#
NULL
|
protected
boolean
|
$_enable_xss
Enable XSS flag Determines whether the XSS filter is always active when GET, OPTIONS, HEAD, POST, PUT, DELETE and PATCH data is encountered Set automatically based on config setting |
#
FALSE
|
protected
array
|
$http_status_codes
HTTP status codes and their respective description Note: Only the widely used HTTP status codes are used |
#
[
self::HTTP_OK => 'OK',
self::HTTP_CREATED => 'CREATED',
self::HTTP_NO_CONTENT => 'NO CONTENT',
self::HTTP_NOT_MODIFIED => 'NOT MODIFIED',
self::HTTP_BAD_REQUEST => 'BAD REQUEST',
self::HTTP_UNAUTHORIZED => 'UNAUTHORIZED',
self::HTTP_FORBIDDEN => 'FORBIDDEN',
self::HTTP_NOT_FOUND => 'NOT FOUND',
self::HTTP_METHOD_NOT_ALLOWED => 'METHOD NOT ALLOWED',
self::HTTP_NOT_ACCEPTABLE => 'NOT ACCEPTABLE',
self::HTTP_CONFLICT => 'CONFLICT',
self::HTTP_INTERNAL_SERVER_ERROR => 'INTERNAL SERVER ERROR',
self::HTTP_NOT_IMPLEMENTED => 'NOT IMPLEMENTED'
]
|