Router.php 843 B

123456789101112131415161718192021222324252627282930313233
  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. $routeCollector->get('/ProductService','/skuState');
  25. }
  26. }