Files
crypto/provm/common/Define/Controller/JSON.php
2021-06-28 23:15:13 -04:00

14 lines
360 B
PHP

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