turned the redirect thing into a loadable host_redirect middleware

This commit is contained in:
2011-12-25 09:51:42 +00:00
parent 533cf0822b
commit 349e9eaef6
4 changed files with 30 additions and 14 deletions

View File

@@ -0,0 +1,16 @@
(function() {
module.exports = function(redirect_map) {
if (redirect_map == null) redirect_map = {};
return function(req, res, next) {
var host;
host = req.header('Host');
if (redirect_map[host]) {
return res.redirect(redirect_map[host]);
} else {
return next();
}
};
};
}).call(this);