Skip to content

Commit

Permalink
Assign request arguments to proper method container, minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cnanney committed Jan 20, 2012
1 parent 6be49b5 commit 6b174b5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions application/libraries/REST_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public function __construct()
if ($this->request->format and $this->request->body)
{
$this->request->body = $this->format->factory($this->request->body, $this->request->format)->to_array();
// Assign payload arguments to proper method container
$this->{'_'.$this->request->method.'_args'} = $this->request->body;
}

// Merge both for one mega-args variable
Expand Down Expand Up @@ -244,15 +246,15 @@ public function response($data = array(), $http_code = null)
{
// all the compression settings must be done before sending any headers
// if php is not handling the compression by itself
if (@ini_get('zlib.output_compression') == FALSE) {
// ob_gzhandler depends on zlib
if (extension_loaded('zlib')) {
// if the client supports GZIP compression
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
ob_start('ob_gzhandler');
}
}
}
if (@ini_get('zlib.output_compression') == FALSE) {
// ob_gzhandler depends on zlib
if (extension_loaded('zlib')) {
// if the client supports GZIP compression
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
ob_start('ob_gzhandler');
}
}
}

is_numeric($http_code) OR $http_code = 200;

Expand Down Expand Up @@ -434,8 +436,8 @@ protected function _detect_method()
protected function _detect_api_key()
{

// Get the api key name variable set in the rest config file
$api_key_variable = config_item('rest_key_name');
// Get the api key name variable set in the rest config file
$api_key_variable = config_item('rest_key_name');

// Work out the name of the SERVER entry based on config
$key_name = 'HTTP_' . strtoupper(str_replace('-', '_', $api_key_variable));
Expand Down

0 comments on commit 6b174b5

Please sign in to comment.