Browse Source

catch 404 and 405 exceptions

main
Aaron Parecki 8 years ago
parent
commit
f70b918e1f
1 changed files with 15 additions and 4 deletions
  1. +15
    -4
      public/index.php

+ 15
- 4
public/index.php View File

@ -23,9 +23,20 @@ $router->addRoute('GET', '/logout', 'Auth::logout');
$router->addRoute('POST', '/login/start', 'Auth::login_start');
$router->addRoute('GET', '/login/callback', 'Auth::login_callback');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
try {
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
} catch(League\Route\Http\Exception\NotFoundException $e) {
$response = new Response;
$response->setStatusCode(404);
$response->setContent("Not Found\n");
$response->send();
} catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
$response = new Response;
$response->setStatusCode(405);
$response->setContent("Method not allowed\n");
$response->send();
}

Loading…
Cancel
Save