Skip to content

Commit 420c1ff

Browse files
author
Kevin Wood-Friend
committed
Added support for allowing alternate HTTP methods
1 parent bf37537 commit 420c1ff

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

application/libraries/REST_Controller.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ abstract class REST_Controller extends CI_Controller
3131
*/
3232
protected $methods = array();
3333

34+
/**
35+
* List of allowed HTTP methods
36+
*
37+
* @var array
38+
*/
39+
protected $allowed_http_methods = array('get', 'delete', 'post', 'put');
40+
3441
/**
3542
* General request data and information.
3643
* Stores accept, language, body, headers, etc.
@@ -320,7 +327,7 @@ public function response($data = array(), $http_code = null)
320327
{
321328
$http_code = 404;
322329

323-
//create the output variable here in the case of $this->response(array());
330+
// create the output variable here in the case of $this->response(array());
324331
$output = NULL;
325332
}
326333

@@ -492,7 +499,7 @@ protected function _detect_output_format()
492499
/**
493500
* Detect method
494501
*
495-
* Detect which method (POST, PUT, GET, DELETE) is being used
502+
* Detect which HTTP method is being used
496503
*
497504
* @return string
498505
*/
@@ -512,7 +519,7 @@ protected function _detect_method()
512519
}
513520
}
514521

515-
if (in_array($method, array('get', 'delete', 'post', 'put')))
522+
if (in_array($method, $this->allowed_http_methods) && method_exists($this, '_parse_' . $method))
516523
{
517524
return $method;
518525
}

0 commit comments

Comments
 (0)