poa / httprouter
基于POA洋葱圈模型的路由器中间件,通过实现路由规则来定制路由器具体的动作
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/poa/httprouter
Requires
- php: >=7.4
- poa/httpserver: ~0.1.0
- poa/middleware: ~0.1.0
- psr/http-message: *
This package is auto-updated.
Last update: 2025-09-25 00:45:16 UTC
README
基于POA洋葱圈模型的路由器中间件,通过实现路由规则来定制路由器具体的动作
作者
安装
{ "require": { "poa/httprouter": "~0.1" } }
composer update
或
composer install poa/httprouter
示例
use Poa\Http\Router\CallableResult; use Poa\Http\Router\Router; use Poa\Http\Router\RouteResultInterface; use Poa\Http\Router\RouteRulerInterface; use Poa\Http\Server\HttpApplication; use Poa\Http\Server\HttpContext; class SimpleRuler implements RouteRulerInterface { public function process(HttpContext $context): ?RouteResultInterface { if ($context->request->getMethod() === 'get') { return new CallableResult(function () { echo 'do something'; }); } return null; } } $router = new Router(); $router->addRuler(new SimpleRuler()); $app = new HttpApplication(); $app->use($router); $app->handle(new HttpContext($request, $responst));
License
The MIT License (MIT). Please see License File for more information.