Kernel
class. All middleware are just classes that contain a before
method and after
method.Kernel
file and are http_middleware
and route_middleware
.http_middleware
is a simple list which should contain your middleware classes. This attribute is a list because all middleware will simply run in succession one after another, similar to Django middlewareKernel
file this type of middleware may look something like:config/middleware.py
file this might look something like:By default, all routes inside theweb.py
file will run theweb
middleware list
:
symbol next to your route middleware name and then pass in those parameters to the before
and after
middleware methods.:
splice we can also use the @
in the value to pass the value of the parameter./dashboard/152/settings
then the value of 152 will be passed to the middleware before and after methods.after
method instead..middleware()
method onto our routes. This will look something like: