In the documentation it says:
You can provide multiple callback functions that behave just like middleware, except these callbacks can invoke next('route') to bypass the remaining route callback(s). You can use this mechanism to impose pre-conditions on a route, then pass control to subsequent routes if there’s no reason to proceed with the current route.
Does this mean that if I write a route like this:
app.get('/', function(req, res, next) {
if (!req.params.id) {
res.statusCode(400).send({error: "id parameter is required"});
next('route');
} else {
next();
}
}, function(req, res) {
res.send({something: 'something'})
});
and params.id
was undefined
, then the next route wouldn't be executed, but if it was present it would?
Basically the coding/naming convention is a little bit confusing me. Why not next(false)
instead of next('route')
?