diff --git a/src/Message/Response.php b/src/Message/Response.php index edd6245b..513cc4d7 100644 --- a/src/Message/Response.php +++ b/src/Message/Response.php @@ -141,10 +141,11 @@ public static function html($html) * ``` * * @param mixed $data + * @param int|null $status * @return self * @throws \InvalidArgumentException when encoding fails */ - public static function json($data) + public static function json($data, $status = self::STATUS_OK) { $json = @\json_encode( $data, @@ -159,7 +160,7 @@ public static function json($data) ); } - return new self(self::STATUS_OK, array('Content-Type' => 'application/json'), $json . "\n"); + return new self($status ? $status : self::STATUS_OK, array('Content-Type' => 'application/json'), $json . "\n"); } /**