RoutingMiddleware
in package
implements
MiddlewareInterface
The routing middleware is one of the central components of Spitfire, it allows the application to receive the request, and produce a response based on the routes that the developers designed for the application.
This middleware is instanced by the webkernel, together with the router that it needs in order to locate the appropriate controller.
Interfaces, Classes and Traits
- MiddlewareInterface
Table of Contents
- $router : Router
- This router will be used to generate a response. Please note that we instance it and do not use any gloabl functions to retrieve it. This provides us with a way more powerful mechanism for testing and reduces the cohesion of the components significantly.
- __construct() : mixed
- process() : ResponseInterface
- This routing middleware is based on the work of the PHP-FIG PSR15 working group, it asks the router to query the current request for a matching route, and if it is found. If this is the case, we generate a response from the route.
Properties
$router
This router will be used to generate a response. Please note that we instance it and do not use any gloabl functions to retrieve it. This provides us with a way more powerful mechanism for testing and reduces the cohesion of the components significantly.
private
Router
$router
Methods
__construct()
public
__construct(Router $router) : mixed
Parameters
- $router : Router
Return values
mixed —process()
This routing middleware is based on the work of the PHP-FIG PSR15 working group, it asks the router to query the current request for a matching route, and if it is found. If this is the case, we generate a response from the route.
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface