mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-29 18:46:20 -05:00
22 lines
404 B
JavaScript
22 lines
404 B
JavaScript
/**
|
|
* Constructor
|
|
*/
|
|
function Handler (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);
|
|
};
|