Stable release of middleware dispatcher package was tagged.
The package is a PSR-15 middleware dispatcher. Given a set of middleware and a
request instance, dispatcher executes it is produces a response instance.
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
$dispatcher = new MiddlewareDispatcher(
new MiddlewareFactory($diContainer),
$eventDispatcher
)->withMiddlewares([
static function (): ResponseInterface {
return new Response(418);
},
]);
$request = new ServerRequest('GET', '/teapot');
$response = $dispatcher->dispatch($request, $this->getRequestHandler());
More details are available in the package readme.