# HttpSoft\Router middleware
All middleware contains only one public method
public function process( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Server\RequestHandlerInterface $handler ): Psr\Http\Message\ResponseInterface;
Using the route collector, it matches the incoming request with the added routes. If a match occurs, registers an instance of HttpSoft\Router\Route as a request attribute, using the
HttpSoft\Router\Route class name as the attribute name, and passes the request to the next middleware. If no route matches the request, then the request will not be modified.
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 the existence of a matching route (instance of HttpSoft\Router\Route) as an attribute in the request. If it exists, the handler for this route is used, otherwise the request processing is delegated to the handler, which is passed as an argument to the
public function __construct(HttpSoft\Runner\MiddlewareResolverInterface $resolver);