Router.php 711 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace EasySwoole\HttpAnnotation\Tests\TestController;
  3. use EasySwoole\Http\AbstractInterface\AbstractRouter;
  4. use EasySwoole\Http\Request;
  5. use EasySwoole\Http\Response;
  6. use EasySwoole\HttpAnnotation\Utility\Scanner;
  7. use FastRoute\RouteCollector;
  8. class Router extends AbstractRouter
  9. {
  10. public function initialize(RouteCollector $routeCollector)
  11. {
  12. $scanner = new Scanner();
  13. $scanner->mappingRouter($routeCollector, __DIR__ . '/RouterPath.php', __NAMESPACE__);
  14. $this->setGlobalMode(true);
  15. $this->setRouterNotFoundCallBack(function (Request $request, Response $response) {
  16. $response->write('not found!');
  17. return false;
  18. });
  19. }
  20. }