Skip to content

Commit 4c3b7c2

Browse files
Merge pull request chriskacerguis#424 from JCBuck/patch-1
Response Code Logging
2 parents 7de88e4 + 1c7d740 commit 4c3b7c2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

application/config/rest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@
334334
`time` int(11) NOT NULL,
335335
`rtime` float DEFAULT NULL,
336336
`authorized` tinyint(1) NOT NULL,
337+
`response_code` smallint(3) NOT NULL,
337338
PRIMARY KEY (`id`)
338339
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
339340
|

application/libraries/REST_Controller.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ public function response($data = NULL, $http_code = NULL, $continue = FALSE)
500500
}
501501

502502
set_status_header($http_code);
503-
503+
$this->_log_response_code($http_code);
504+
504505
// If zlib.output_compression is enabled it will compress the output,
505506
// but it will not modify the content-length header to compensate for
506507
// the reduction, causing the browser to hang waiting for more data.
@@ -1568,7 +1569,20 @@ protected function _log_access_time()
15681569

15691570
return $this->rest->db->update(config_item('rest_logs_table'), $payload, array('id' => $this->_insert_id));
15701571
}
1571-
1572+
1573+
/**
1574+
* updates the log with response code result
1575+
*
1576+
* @author Justin Chen
1577+
* @return boolean
1578+
*/
1579+
1580+
protected function _log_response_code($http_code)
1581+
{
1582+
$payload['response_code'] = $http_code;
1583+
return $this->rest->db->update(config_item('rest_logs_table'), $payload, array('id' => $this->_insert_id));
1584+
}
1585+
15721586
/**
15731587
* Check to see if the API key has access to the controller and methods
15741588
*

0 commit comments

Comments
 (0)