Skip to content

Instantly share code, notes, and snippets.

@ivoputzer
Created May 11, 2016 14:50
Show Gist options
  • Save ivoputzer/78483a0b632b63b44f3472c48d33ab70 to your computer and use it in GitHub Desktop.
Save ivoputzer/78483a0b632b63b44f3472c48d33ab70 to your computer and use it in GitHub Desktop.
simple http logger nodejs
const http = require('http')
http.createServer((req, res) => {
console.log('-- url:', req.url)
console.log('-- verb:', req.method)
let body = []
req.on('data', function(chunk) {
body.push(chunk)
}).on('end', function() {
console.log('-- body:', Buffer.concat(body).toString())
delete body
})
res.statusCode = 200
res.end('')
}).listen(8088, () => {
console.log('-- server started on http://0.0.0.0:8088')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment