How is a route handler related to middleware?
A route handler is just a final middleware. It is the last function in the chain for that route. The same (req, res, next) signature applies, but handlers usually send the response instead of calling next.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Is Express Middleware? Explained With Examples
A function with the signature (req, res, next) that runs on requests. It can modify req, send a response, call next to continue, or call next(err) to jump to the error handler. Almost everything in Express is middleware.
Modify req (e.g., set req.user from JWT), send a response and end the cycle, call next() to pass to the next middleware, or call next(err) to jump to the error handler.
App-level (app.use), router-level (router.use), built-in (express.json), third-party (cors, helmet), and error-handling (four parameters: err, req, res, next).
Still have questions?
Browse all our FAQs or reach out to our support team
