Skip to content

Instantly share code, notes, and snippets.

@framlin
Created April 6, 2012 07:44
Show Gist options
  • Save framlin/2317972 to your computer and use it in GitHub Desktop.
Save framlin/2317972 to your computer and use it in GitHub Desktop.
var union = require('union');
var flatiron = require('flatiron');
var winston = require('winston');
var ecstatic = require('ecstatic');
var url = require('url');
var util = require('util');
app = new flatiron.App();
app.use(flatiron.plugins.http);
function getIP(req) {
return {
ip: ( req.headers["X-Forwarded-For"]
|| req.headers["x-forwarded-for"]
|| req.socket.remoteAddress )
};
};
app.use(function(req, res, next) {
//this does NOT LOG
winston.log.info("REQ - use-app");
next();
});
app.http.before = [
//this throws exception
//TypeError: Cannot read property 'remoteAddress' of undefined",
// " at Array.0 (/home/framlin/workspace/egger/server/run.js:30:51)",
function (req, res) {
app.log.info("REQ - hello client" + req.socket.remoteAddress);
res.emit('next');
},
ecstatic(__dirname + '/../site')
];
app.start(8081);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment