You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Broker is a dead simple PSR-15 middleware dispatcher. Broker implements
both RequestHandlerInterface and MiddlewareInterface for maximum flexibility.
Install
composer require northwoods/broker
Usage
useAcme\Middleware;
useNorthwoods\Broker\Broker;
/** @var \Psr\Http\Message\ServerRequestInterface */$request = /* any server request */;
// Use append() or prepend() to add middleware$broker = newBroker();
$broker->append(newMiddleware\ParseRequest());
$broker->prepend(newMiddleware\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.