You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.7 KiB

9 years ago
9 years ago
  1. <?php
  2. chdir('..');
  3. include('vendor/autoload.php');
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. $router = new League\Route\RouteCollection;
  7. $templates = new League\Plates\Engine(dirname(__FILE__).'/../views');
  8. $router->addRoute('GET', '/', 'Controller::index');
  9. $router->addRoute('GET', '/dashboard', 'Controller::dashboard');
  10. $router->addRoute('GET', '/api', 'Controller::api');
  11. $router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
  12. $router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
  13. $router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
  14. $router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
  15. $router->addRoute('POST', '/webmention', 'API::webmention');
  16. $router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
  17. $router->addRoute('GET', '/login', 'Auth::login');
  18. $router->addRoute('GET', '/logout', 'Auth::logout');
  19. $router->addRoute('POST', '/login/start', 'Auth::login_start');
  20. $router->addRoute('GET', '/login/callback', 'Auth::login_callback');
  21. $dispatcher = $router->getDispatcher();
  22. $request = Request::createFromGlobals();
  23. try {
  24. $response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
  25. $response->send();
  26. } catch(League\Route\Http\Exception\NotFoundException $e) {
  27. $response = new Response;
  28. $response->setStatusCode(404);
  29. $response->setContent("Not Found\n");
  30. $response->send();
  31. } catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
  32. $response = new Response;
  33. $response->setStatusCode(405);
  34. $response->setContent("Method not allowed\n");
  35. $response->send();
  36. }