Middleware என்பது வலை சேவையகத்திற்கும் உங்கள் views களுக்கும் இடையில் உட்கார்ந்து ஒவ்வொரு request மற்றும் response ஐயும் உலகளாவியாக செயலாக்கும் hooks களின் ஒரு கட்டமைப்பு. ஒவ்வொரு middleware யும் requests களை பரிசோதிக்கவோ/மாற்றவோ முடியும் மற்றும் responses களை திருத்தமாக வெளியேற்றலாம் — இது authentication, security headers, sessions, மற்றும் logging போன்ற cross-cutting concerns களுக்கு சிறந்தது.
Middleware மூலம் request/response flow
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)
