app.get('/path/:name', function(req, res) { // url: /path/test
console.log(req.params.name); // result: test
});
// OR
app.get('/path', function(req, res) { // url: /path?name='test'
console.log(req.query['name']); // result: test
});
app.get('/path/:name', function(req, res) {
res.send("tagId is set to " + req.params.name);
});
app.get('/p/:tagId', function(req, res) {
res.send("tagId is set to " + req.params.tagId);
});
// GET /p/5
// tagId is set to 5
app.param(['id', 'page'], function (req, res, next, value) {
console.log('CALLED ONLY ONCE with', value)
next()
})
app.get('/user/:id/:page', function (req, res, next) {
console.log('although this matches')
next()
})
app.get('/user/:id/:page', function (req, res) {
console.log('and this matches too')
res.end()
})