I am trying to create a middleware that can accept parameters. How can this be done?
example
app.get('/hasToBeAdmin', HasRole('Admin'), function(req,res){
})
HasRole = function(role, req, res, next){
if(role != user.role){
res.redirect('/NotInRole);
}
next();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…