Json controller trait

This commit is contained in:
2021-03-15 17:47:13 -03:00
commit 4c6c6f0d6d

View File

@ -0,0 +1,13 @@
<?php
namespace ProVM\Common\Define\Controller;
use Psr\Http\Message\ResponseInterface as Response;
trait Json {
public function withJson(Response $response, $output, $status = 200) {
$response->getBody()->write(json_encode($output));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus($status);
}
}