Middleware is a framework of hooks that process every request and response globally, sitting between the web server and your views. Each middleware can inspect/modify requests on the way in and responses on the way out — ideal for cross-cutting concerns like authentication, security headers, sessions, and logging.
An sreabh iarratas/freagra trí dhréimire
Request → MW1 → MW2 → MW3 → VIEW
Response ← MW1 ← MW2 ← MW3 ← VIEW
Middleware wraps the view like layers of an onion:
- on the way IN (request): top-to-bottom
- on the way OUT (response): bottom-to-top (reverse order)
