mirror of
https://github.com/jimeh/heartb.it.git
synced 2026-02-19 12:56:47 +00:00
turned the redirect thing into a loadable host_redirect middleware
This commit is contained in:
16
middleware/host_redirect.js
Normal file
16
middleware/host_redirect.js
Normal 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);
|
||||
Reference in New Issue
Block a user