| @@ 13-32 (lines=20) @@ | ||
| 10 | */ |
|
| 11 | namespace Infuse; |
|
| 12 | ||
| 13 | class MethodNotAllowedHandler |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @param Request $req |
|
| 17 | * @param Response $res |
|
| 18 | * @param array $allowedMethods |
|
| 19 | * |
|
| 20 | * @return Response |
|
| 21 | */ |
|
| 22 | public function __invoke($req, $res, $allowedMethods) |
|
| 23 | { |
|
| 24 | if ($req->isHtml()) { |
|
| 25 | $res->render(new View('method_not_allowed', [ |
|
| 26 | 'title' => 'Method Not Allowed', |
|
| 27 | 'allowedMethods' => $allowedMethods, ])); |
|
| 28 | } |
|
| 29 | ||
| 30 | return $res->setCode(405); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| @@ 13-29 (lines=17) @@ | ||
| 10 | */ |
|
| 11 | namespace Infuse; |
|
| 12 | ||
| 13 | class NotFoundHandler |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @param Request $req |
|
| 17 | * @param Response $res |
|
| 18 | * |
|
| 19 | * @return Response |
|
| 20 | */ |
|
| 21 | public function __invoke($req, $res) |
|
| 22 | { |
|
| 23 | if ($req->isHtml()) { |
|
| 24 | $res->render(new View('not_found', ['title' => 'Not Found'])); |
|
| 25 | } |
|
| 26 | ||
| 27 | return $res->setCode(404); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||