How can I merge these two get requests into one?
app.get('/:something/:else', function(req, res){
res.render("something");
});
app.get('/:something', function(req, res){
res.render("something");
});
I tried this and it didn’t work.
app.get('(/:something|/:something/:else)', function(req, res){
res.render("something");
});
I am not 100% sure but I think you can do:
Otherwise you can either store the middleware function in a variable:
Or you can use a regular expression.
There is some info on the Express.js site: http://expressjs.com/api.html#app.VERB
The author also has a client-side library that is based on Express.js routing so maybe you can find more info there. That’s where I could the ‘?’ example. The library is called page.js and can be found: http://visionmedia.github.com/page.js/