public
Created

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.