Files
This commit is contained in:
13
common/Define/Controller/Json.php
Normal file
13
common/Define/Controller/Json.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace Incoviba\API\Common\Define\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
|
||||
trait Json {
|
||||
public function withJson(Response $response, $data, $status = 200): Response {
|
||||
$response->getBody()->write(json_encode($data, JSON_UNESCAPED_SLASHES));
|
||||
return $response
|
||||
->withStatus($status)
|
||||
->withHeader('content-type', 'application/json');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user