RoutingMiddleware
Solo\Application\RoutingMiddleware matches the request against the router, stores the route in request attributes and runs the route's own middleware before passing the request on. See Routing for usage.
final readonly class RoutingMiddleware implements Psr\Http\Server\MiddlewareInterfaceApplication registers it in the container with $app->router, so list it as RoutingMiddleware::class.
__construct()
public function __construct(
Solo\Router\Router $router,
ContainerInterface $container,
)$router is the built router to match against. $container resolves route middleware given as IDs.
process()
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterfaceResolves the request method and path with
Router::resolve(). The path is the one the client sent, with a leading slash and with only percent-encoded non-ASCII bytes decoded.Throws
RouteNotFoundExceptionif no route matches, orMethodNotAllowedExceptionwith the allowed methods if the path exists for other methods.Percent-decodes the parameters and throws
InvalidRouteParameterExceptionif one contains a control character (\x00–\x1F,\x7F).Adds the request attributes:
Attribute Value RequestAttribute::HANDLER$route->handlerRequestAttribute::PARAMSThe decoded parameters, array<string, string>RequestAttribute::ROUTE_NAME$route->name, ornullRequestAttribute::ROUTE_ATTRIBUTES$route->attributesRuns
$route->middlewares— group middleware from the outermost group in, then the route's own — in aMiddlewarePipelinewhose final handler is$handler, and returns its response.
Throws the routing exceptions above, and whatever the route middleware or the rest of the pipeline throw.