Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
http.createServer(function(req, res) {
var ip = req.connection.remoteAddress;
.deliver(WEBROOT, req, res)
.addHeader('Expires', 300)
.addHeader('X-PaperRoute', 'Node')
.before(function() {
sys.log('Recieved Request')
.after(function(statCode) {
res.write('Delivered: '+req.url);
log(statCode, req.url, ip);
.error(function(statCode,msg) {
res.writeHead(statCode, {'Content-Type': 'text/plain'});
res.write("Error: " + statCode);
log(statCode, req.url, ip, msg);
.otherwise(function(err) {
var statCode = 404;
res.writeHead(statCode, {'Content-Type': 'text/plain'});
log(statCode, req.url, ip, err);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment