northwoods/broker
最新稳定版本:3.0.0
Composer 安装命令:
composer require northwoods/broker
包简介
Dead simple PSR-15 middleware dispatcher
README 文档
README
Broker is a dead simple PSR-15 middleware dispatcher. Broker implements
both RequestHandlerInterface and MiddlewareInterface for maximum flexibility.
Install
composer require northwoods/broker
Usage
use Acme\Middleware; use Northwoods\Broker\Broker; /** @var \Psr\Http\Message\ServerRequestInterface */ $request = /* any server request */; // Use append() or prepend() to add middleware $broker = new Broker(); $broker->append(new Middleware\ParseRequest()); $broker->prepend(new Middleware\CheckIp()); /** @var \Psr\Http\Message\ResponseInterface */ $response = $broker->handle($request);
append(...$middleware)
Add one or more middleware to the end of the stack.
prepend(...$middleware)
Add one or more middleware to be beginning of the stack.
handle($request)
Dispatch the middleware stack as a request handler. If the end of the stack is
reached and no response has been generated, an OutOfBoundsException will
be thrown.
process($request, $handler)
Dispatch the middleware stack as a middleware. If the end of the stack is reached
and no response has been generated, the $handler will be called.
Suggested Packages
- Conditional middleware execution can be provided by northwoods/conditional-middleware
- Lazy middleware instantiation can be provided by northwoods/lazy-middleware
- Response sending can be provided by http-interop/response-sender
统计信息
- 总下载量: 97.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 1
- 依赖项目数: 5
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-21