Suppose I have two router:
app.get('blog/show', function () {
todo();
})
app.get('/admin', function () {
todo();
})
Can I the merge the two router to the same app.get method?Mybe something like app.get('blog/show', '/admin').
Is there a way to do that?
As bryanmac mentioned, you can do this by specifying the route path as a regex that matches either case:
app.get(/blog\/show|\/admin/, function () {
todo();
});
Of course, you could also have both routes use the same named function:
function handler() {
todo();
}
app.get('blog/show', handler);
app.get('/admin', handler);