Added code for redirects and now redirecting the donation URL to the proper location. Fixes #412.

This commit is contained in:
Shane M. Clements 2016-04-09 10:04:39 -06:00
parent 10455f980f
commit cbc58d2f11
3 changed files with 11 additions and 3 deletions

View file

@ -10,6 +10,11 @@ var config = require('./config');
* Constructor
*/
function Handler (route) {
// Handle redirects
if (route.redirect) {
return (req, res) => res.redirect(route.redirect);
}
// Route definition
defaults(route, config);

View file

@ -45,10 +45,9 @@ app.use(function (req, res, next) {
});
// Bind routes
for (var routeId in routes) {
var route = routes[routeId];
routes.forEach(route => {
app.get(route.pattern, handler(route));
}
});
if (typeof process.env.NODE_SENTRY_DSN === 'string') {
var raven = require('raven');

View file

@ -43,5 +43,9 @@
"pattern": "/wedo",
"view": "wedo2",
"title": "LEGO WeDo 2.0"
},
{
"pattern": "/info/donate/",
"redirect": "https://secure.donationpay.org/scratchfoundation/"
}
]