Router.php 740 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\HttpController;
  3. use EasySwoole\Http\AbstractInterface\AbstractRouter;
  4. use EasySwoole\Http\Request;
  5. use EasySwoole\Http\Response;
  6. use FastRoute\RouteCollector;
  7. class Router extends AbstractRouter
  8. {
  9. function initialize(RouteCollector $routeCollector)
  10. {
  11. /*
  12. * eg path : /router/index.html ; /router/ ; /router
  13. */
  14. $routeCollector->get('/router','/test');
  15. /*
  16. * eg path : /closure/index.html ; /closure/ ; /closure
  17. */
  18. $routeCollector->get('/closure',function (Request $request,Response $response){
  19. $response->write('this is closure router');
  20. //不再进入控制器解析
  21. return false;
  22. });
  23. }
  24. }