Reputation: 1826
In Express js, I register a route like this:
module.exports = function(app) {
app.get('/user/new', function(req, res) {
res.render('user/new', {title: "Register"});
});
}
How can I retrieve the callback function from that '/user/new' route, meaning to retrieve back the function below:
function(req, res) {
res.render('user/new', {title: "Register"});
}
Upvotes: 3
Views: 180
Reputation: 203514
Bit of a hack:
var handler = app._router.match('get', '/user/new').callbacks[0];
Upvotes: 3