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.

45 lines
1.8 KiB

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