This commit is contained in:
2020-02-27 19:09:54 -03:00
parent 17b62d528e
commit 467fab3716
35 changed files with 478 additions and 0 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace ProVM\Common\Basic;
use Psr\Http\Message\ResponseInterface as Response;
use ProVM\Common\Definition\Controller as ControllerInterface;
abstract class Controller implements ControllerInterface {
public function withJSON(Response $response, string $data): Response {
$response->getBody()->write(json_encode($data));
return $response
->withHeader('Content-Type', 'application/json')
->withStatus(201);
}
public function withRedirect(string $uri): Response {
return $response
->withHeader('Location', $uri)
->withStatus(303);
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace ProVM\Common\Definition;
use Psr\Http\Message\ResponseInterface as Response;
interface Controller {
public function withJSON(Response $response, string $data): Response;
public function withRedirect(string $uri): Response;
}