I am using the Express framework in node.js with some middleware functions:
var app = express.createServer(options);
app.use(User.checkUser);
I can use the .use
function with an additional parameter to use this middleware only on specific paths:
app.use('/userdata', User.checkUser);
Is it possible to use the path variable so that the middleware is used for all paths except a specific one, i.e. the root path?
I am thinking about something like this:
app.use('!/', User.checkUser);
So User.checkUser
is always called except for the root path.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…