14 lines
354 B
PHP
14 lines
354 B
PHP
<?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);
|
|
}
|
|
}
|