module.exports.routes = {
'GET /blog/:year/:month/:day/:posttitle/': 'BlogController.showPost',
'GET /blog/:year/:month/:day/': 'BlogController.showDayArchive',
'GET /blog/:year/:month/': 'BlogController.showMonthArchive',
'GET /blog/:year/': 'BlogController.showYearArchive',
};
The parameters passed in the URL can then be accessed in the corresponding controller actions using req.param('year')
, req.param('month')
etc.
For example, a GET
request to /blog/2016/08/
triggers the BlogController.showMonthArchive
controller action, with req.param('year')
having the value 2016
and req.param('month')
having the value 08
.