Created
May 11, 2016 14:50
-
-
Save ivoputzer/78483a0b632b63b44f3472c48d33ab70 to your computer and use it in GitHub Desktop.
simple http logger nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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