Stack of configured routes
Map the given param placeholder name
(s) to the given callback(s).
Parameter mapping is used to provide pre-conditions to routes which use normalized placeholders. For example a :user_id parameter could automatically load a user's information from the database without any additional code,
The callback uses the samesignature as middleware, the only differencing
being that the value of the placeholder is passed, in this case the id
of the user. Once the next()
function is invoked, just like middleware
it will continue on to execute the route, or subsequent parameter functions.
app.param('user_id', function(req, res, next, id){
User.find(id, function(err, user){
if (err) {
next(err);
} else if (user) {
req.user = user;
next();
} else {
next(new Error('failed to load user'));
}
});
});
Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param()
Generated using TypeDoc
Special-cased "all" method, applying the given route
path
, middleware, and callback to every HTTP method.