2018-01-30 10:33:15 -05:00
|
|
|
/*
|
2016-04-18 14:07:11 -04:00
|
|
|
* Constructor
|
|
|
|
*/
|
2018-01-30 10:33:15 -05:00
|
|
|
const Handler = function (route) {
|
2016-04-09 12:04:39 -04:00
|
|
|
// Handle redirects
|
|
|
|
if (route.redirect) {
|
2018-01-30 10:33:15 -05:00
|
|
|
return (req, res) => {
|
|
|
|
res.redirect(route.redirect);
|
|
|
|
};
|
2016-04-09 12:39:55 -04:00
|
|
|
}
|
2016-04-18 14:07:11 -04:00
|
|
|
|
2016-04-22 09:07:12 -04:00
|
|
|
var url = '/' + route.name + '.html';
|
2016-04-18 14:07:11 -04:00
|
|
|
return function (req, res, next) {
|
|
|
|
req.url = url;
|
|
|
|
next();
|
|
|
|
};
|
2018-01-30 10:33:15 -05:00
|
|
|
};
|
2016-04-18 14:07:11 -04:00
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
/*
|
2016-04-18 14:07:11 -04:00
|
|
|
* Export a new instance
|
|
|
|
*/
|
|
|
|
module.exports = function (route) {
|
|
|
|
return new Handler(route);
|
|
|
|
};
|