Middleware είναι ένα framework από hooks που επεξεργάζονται κάθε request και response παγκοσμίως, βρίσκεται ανάμεσα στον web server και τις views σας. Κάθε middleware μπορεί να επιθεωρήσει/τροποποιήσει requests στην διαδρομή εισόδου και responses στην διαδρομή εξόδου — ιδανικό για cross-cutting concerns όπως authentication, security headers, sessions, και logging.
Η ροή request/response μέσα από 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)
