This patch adds a new optional constructor argument to the RouteMiddlewareFactory, a string $routerServiceName. By default, it uses Zend\Expressive\Router\RouterInterface for the value. Users can, however, specify an alternate service class. This allows users to vary the RouteMiddleware per module or path-segregated middleware pipeline:
// In configuration:
return [
'dependencies' => [
'factories' => [
\Api\Router::class => FastRouteRouterFactory::class,
\Api\RouteMiddleware::class => new RouteMiddlewareFactory(\Api\Router::class),
],
],
],
// In config/pipeline.php:
$app->pipe('/api', [
\Api\RouteMiddleware::class,
DispatchMiddleware::class,
]);
The factory implements __set_state(), allowing serialization via var_export() (the mechanism used by the default expressive configuration caching mechanism).
This patch adds a new optional constructor argument to the
RouteMiddlewareFactory
, a string$routerServiceName
. By default, it usesZend\Expressive\Router\RouterInterface
for the value. Users can, however, specify an alternate service class. This allows users to vary theRouteMiddleware
per module or path-segregated middleware pipeline:The factory implements
__set_state()
, allowing serialization viavar_export()
(the mechanism used by the default expressive configuration caching mechanism).