v0.2.0
This commit is contained in:
19
provm/common/Basic/Controller.php
Normal file
19
provm/common/Basic/Controller.php
Normal 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);
|
||||
}
|
||||
}
|
9
provm/common/Definition/Controller.php
Normal file
9
provm/common/Definition/Controller.php
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user