I'd like to configure middleware behavior on a route by route basis.
What I can do now
app.get('/special', function(req, res, next) {
req.isSpecial = true
next()
})
app.get('*', function(req, res, next) {
if (req.isSpecial) req.special = superSpecialStuff()
next()
})
app.get('/special', function(req, res) {
req.special.doSpecialStuff()
})
Basically, I want to make the middleware behave differently for certain routes, then use results from that middleware. Can I do this without having to split the definition of /special into two parts?
I'd like to be able to do something like
app.get('/special', function(req, res, next) {
// configure middleware
req.isSpecial = true
}, function(req, res) {
req.special.doSpecialStuff()
})
Basically "before middleware" and "after middleware" callbacks.