HTTP Middlewares provide a convenient mechanism for filtering HTTP requests entering your application. Laravel, for example, has a middleware for verifying a user’s authentication.
Some Middleware Use-Cases
- Using a middleware to confirm the incoming route request API key. Assuming you are building an API.
- Rate-limiting a service call.
- Change the site language based on locale.
- Enable site-wide maintenance.
- Sniffing bot traffic.