# HttpSoft\Router middleware
All middleware contains only one public method
public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface;
Uses the route collector to match against the incoming request, and injects the request passed to the handler with the HttpSoft\Router\Route instance matched (using the
HttpSoft\Router\Route class name as the attribute name).
If no route matches the request, the handler will be injected with the request without an instance of the HttpSoft\Router\Route.
public function __construct( HttpSoft\Router\RouteCollector $router, Psr\Http\Message\ResponseFactoryInterface $responseFactory, array $allowedMethods = ['HEAD'] // common allowed request methods for all routes. );
If the request URI matches one of the routes, but the request method does not match that route's method, this middleware will emit a
405 response, along with an
Allow header indicating the allowed route methods.
Checks for a matched route (HttpSoft\Router\Route instance) in the request. If it is passed, the route handler is used, otherwise request processing is delegated to the passed handler.
public function __construct(HttpSoft\Runner\MiddlewareResolverInterface $resolver);