Middleware
Code that runs between receiving a request and sending a response.
Definition
Middleware is a function that sits in the request-response pipeline, processing requests before they reach the final handler. Common uses include logging every request, checking authentication tokens, parsing JSON bodies, and handling errors. Middleware functions run in order, each passing control to the next.
Example
A Node.js Express app uses middleware to check every incoming request for a valid auth token. If the token is missing, the middleware returns a 401 error before the route handler ever runs.
See it in context Learn how Middleware fits into the bigger picture of how software actually works.
Read the Guide →