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

12
app.js
View File

@@ -9,13 +9,6 @@
app.set('views', __dirname + '/views');
app.set('view engine', 'coffee');
app.register('.coffee', require('coffeekup').adapters.express);
app.use(function(req, res, next) {
if (req.header('Host') === 'www.heartb.it') {
return res.redirect('http://heartb.it/');
} else {
return next();
}
});
app.use(express.bodyParser());
app.use(express.methodOverride());
return app.use(express.static(__dirname + '/public'));
@@ -29,7 +22,10 @@
});
app.configure('production', function() {
return app.use(express.errorHandler);
app.use(express.errorHandler());
return app.use(require('./middleware/host_redirect')({
"www.heartb.it": "http://heartb.it"
}));
});
app.get('/', function(req, res) {