Created
February 7, 2016 19:46
-
-
Save pdewouters/d95f86457813749390b2 to your computer and use it in GitHub Desktop.
Convert incoming chunks to uppercase
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 fs = require('fs') | |
var map = require('through2-map') | |
var server = http.createServer((req, res) => { | |
res.writeHead(200,{'Content-type':'text/plain'}) | |
if(req.method != 'POST'){ | |
return res.end('send me a POST\n') | |
} | |
req.pipe(map(chunk=>{ | |
return chunk.toString().toUpperCase() | |
})).pipe(res) | |
}) | |
server.listen(process.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment