Files
api/common/Define/Controller/Json.php

14 lines
391 B
PHP
Raw Normal View History

2021-11-30 18:04:41 -03:00
<?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');
}
}