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

14 lines
367 B
PHP
Raw Normal View History

2021-08-10 15:48:33 -04:00
<?php
namespace Incoviba\Common\Define\Controller;
use Psr\Http\Message\ResponseInterface as Response;
trait Json {
public function withJson(Response $response, $data, int $status = 200): Response {
$response->getBody()->write(json_encode($data));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus($status);
}
}