Middleware provide a convenient mechanism for filtering HTTP requests entering your application.
You can enable and disable Middlewares as you wish.
There are two types of Middlewares, General (applied on all the Routes by default) and Endpoints Middlewares (applied on some Endpoints).
The Middlewares CAN be placed in Ship layer or Container layer depending on its roles.
If a Middleware is written inside a Container then it MUST be registered inside that Container.
To register Middlewares in a Container the container needs to have a
MiddlewareServiceProvider, and like all other Container Providers it MUST be registered in the
MainServiceProviderof that Container.
General Middlewares SHOULD live in the Ship layer
app/Ship/Middlewares/*and are registered in the
Third Party packages Middleware CAN be registered in Containers or on the Ship layer (wherever they make more sense). For example the
jwt.authmiddleware "provided by the JWT package" should be registered in the Authentication Container (
More info at Laravel Docs.