scratch-www/dev-server/handler.js

25 lines
428 B
JavaScript
Raw Normal View History

/*
* Constructor
*/
const Handler = function (route) {
// Handle redirects
if (route.redirect) {
return (req, res) => {
res.redirect(route.redirect);
};
}
2024-01-17 15:40:27 -05:00
const 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);
};