Last active
February 16, 2018 12:45
-
-
Save jrusev/461aa946787c62976de089af6062f61d to your computer and use it in GitHub Desktop.
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
var http = require('http'); | |
var port = 1234; | |
http.createServer(function (req, resp) { | |
var body = []; | |
req.on('data', function (chunk) { body.push(chunk); }); | |
req.on('end', function () { | |
body = Buffer.concat(body).toString(); | |
console.log({headers: req.headers, method: req.method, body: body}); | |
resp.writeHead(200, {'Content-Type': 'text/plain'}); | |
resp.end('OK'); | |
}); | |
}).listen(port); | |
console.log('Server listening on port', port); | |
// $ node server.js | |
// $ curl -i localhost:1234 | |
// $ curl -i -X POST localhost:1234 -H 'Content-Type: application/json' -d '{}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment