scratch-www/dev-server/handler.js
2018-01-30 11:53:12 -05:00

24 lines
431 B
JavaScript

/*
* Constructor
*/
const Handler = function (route) {
// Handle redirects
if (route.redirect) {
return (req, res) => {
res.redirect(route.redirect);
};
}
var url = '/' + route.name + '.html';
return function (req, res, next) {
req.url = url;
next();
};
};
/*
* Export a new instance
*/
module.exports = function (route) {
return new Handler(route);
};