Skip to content

Commit

Permalink
Support 1.2.0 below version json body format
Browse files Browse the repository at this point in the history
  • Loading branch information
yidas committed Mar 31, 2018
1 parent 15fda75 commit 75656bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rest/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* RESTful API Controller
*
* @author Nick Tsai <[email protected]>
* @version 1.3.0
* @version 1.3.1
* @link https://github.com/yidas/codeigniter-rest/
* @see https://github.com/yidas/codeigniter-rest/blob/master/examples/RestController.php
*
Expand Down Expand Up @@ -174,15 +174,15 @@ protected function _format($statusCode=null, $message=null, $body=false)
{
$format = [];
// Status Code field is necessary
$format[$this->responseFormat['status_code']] = ($statusCode)
$format['code'] = ($statusCode)
?: $this->response->getStatusCode();
// Message field
if ($message) {
$format[$this->responseFormat['message']] = $message;
$format['message'] = $message;
}
// Body field
if ($body !== false) {
$format[$this->responseFormat['body']] = $body;
$format['data'] = $body;
}

return $format;
Expand Down

0 comments on commit 75656bb

Please sign in to comment.