Middleware yaiku kerangka saka hooks sing ngolah saben request lan response sacara global, ana ing antarane web server lan views-mu. Saben middleware bisa ngliyati/ngganti requests nalika mlebu lan responses nalika metu — ideal kanggo cross-cutting concerns kayata authentication, security headers, sessions, lan logging.
Flow request/response liwat middleware
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)
