$middleware
Middlewares are classes that can be exported in the entry and allow you to intervene in requests.
Definition
self
Consumes dependencies registered in the IoC context so that they can be used internally by the function.
By default there are a number of registered objects available:
- Request
- Headers
- RequestUrl
- RequestContext
- ResponseHeaders
- AppContext
- Settings created with
$settings
- Sessions created with
$session
It is recommended that the middleware consumes lighter dependencies to avoid loading it with complexity, for example, if you need to access the headers, use Headers and avoid consuming Request.
create
Create an abstract middleware class with the configured instance. You must override the method onRequest
to implement the middleware logic.