Introduction
Middleware runs before request handlers to prepare or check the request. It can change the request or stop it early if needed.
Check if a user is logged in before allowing access to a page.
Log details about every request for monitoring.
Add extra information to requests, like user data.
Block bad requests before they reach the main code.
Modify request data to fit what handlers expect.