Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created April 6, 2010 22:44
Show Gist options
  • Save andrewvc/358221 to your computer and use it in GitHub Desktop.
Save andrewvc/358221 to your computer and use it in GitHub Desktop.
http.createServer(function(req, res) {
var ip = req.connection.remoteAddress;
paperboy
.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);
res.close();
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);
});
}).listen(PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment