Middleware అనేది ఒక ఫ్రేమ్వర్క్ హుక్ల సమితి, ఇది ప్రతి request మరియు response ను గ్లోబల్గా ప్రక్రియ చేస్తుంది, వెబ్ సర్వర్ మరియు మీ views ల మధ్య కూర్చుంది. ప్రతి middleware request ని తనిఖీ చేయటానికి/సవరించటానికి మరియు response ని సవరించటానికి వీలు ఇస్తుంది — authentication, security headers, sessions, మరియు logging లాంటి cross-cutting concerns కోసం ఆదర్శవంతమైనది.
Middleware ద్వారా request/response ప్రవాహం
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)
