Created
March 19, 2013 19:51
-
-
Save narqo/5199497 to your computer and use it in GitHub Desktop.
Тестовый обработчик POST-запроса в Node.js
This file contains hidden or 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
› node htttest.js && curl -d "user=someone" --url http://127.0.0.1:4001 |
This file contains hidden or 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
require('http') | |
.createServer(function(req, res) { | |
req.setEncoding('utf8'); | |
process.nextTick(function() { | |
req.on('data', console.log.bind(null, '+')); // Несработает в Node.js < 0.10.x — promise'ы идут лесом :_( | |
}); | |
req.on('end', function() { | |
res.end('DONE!!!'); | |
}); | |
}) | |
.listen(4001); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment