Skip to content

Commit

Permalink
Merge pull request #199 from spiral/develop
Browse files Browse the repository at this point in the history
Update JsonTrait.php
  • Loading branch information
wolfy-j authored Oct 3, 2017
2 parents 75560b7 + a3b8b7b commit 1f7f91e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/Spiral/Http/Traits/JsonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ private function writeJson(
$json,
int $code = 200
): ResponseInterface {
if ($json instanceof \JsonSerializable) {
$json = $json->jsonSerialize();
}

if (is_array($json) && isset($json['status'])) {
$code = $json['status'];
}
Expand All @@ -36,4 +40,4 @@ private function writeJson(

return $response->withStatus($code)->withHeader('Content-Type', 'application/json');
}
}
}

0 comments on commit 1f7f91e

Please sign in to comment.