http-proxy
Version:
A full-featured http reverse proxy for node.js
24 lines (23 loc) • 2.33 kB
JSON
{
"name": "connect-restreamer",
"version": "1.0.0",
"description": "re-stream a parsed body so that it can be proxied.",
"homepage": "http://github.com/dominictarr/connect-restreamer",
"repository": {
"type": "git",
"url": "https://github.com/dominictarr/connect-restreamer.git"
},
"author": {
"name": "Dominic Tarr",
"email": "dominic.tarr@gmail.com",
"url": "http://bit.ly/dominictarr"
},
"readme": "#connect-restreamer\n\nconnect's bodyParser has a problem when using it with a proxy. It gobbles up all the\nbody events, so that the proxy doesn't see anything!\n\n`connect-restreamer` comes to the rescue by re-emitting the body to the proxy.\n\nit has defaults that make it suitable for use with connect's `bodyParser` but can be customized.\n\n## usage\n\njust include `connect-restreamer` in you're middleware chain after the bodyParser\n\n var bodyParser = require('connect/lib/middleware/bodyParser')\n , restreamer = require('connect-restreamer')\n\n //don't worry about incoming contont type\n //bodyParser.parse[''] = JSON.parse\n\n require('http-proxy').createServer(\n //refactor the body parser and re-streamer into a separate package\n bodyParser(),\n //body parser absorbs the data and end events before passing control to the next\n // middleware. if we want to proxy it, we'll need to re-emit these events after \n //passing control to the middleware.\n require('connect-restreamer')(),\n function (req,res, proxy) {\n //custom proxy logic\n //... see https://github.com/nodejitsu/node-http-proxy\n }\n ).listen(80)\n\n\n## customization\n\nrestreamer takes 3 options:\n\n var options = {\n modify: function(body) {\n //a function that may modify the buffered property\n return body\n },\n property: 'body', //name of the buffered property\n stringify:JSON.stringify //function to turn the buffered object back into a string\n }\n\n require('connect-restreamer')(options)\n",
"readmeFilename": "readme.markdown",
"_id": "connect-restreamer@1.0.0",
"dist": {
"shasum": "4ef5f5ba2f86ed3ee39a7dabdabb6b56469d05c2"
},
"_from": "connect-restreamer@1",
"_resolved": "https://registry.npmjs.org/connect-restreamer/-/connect-restreamer-1.0.0.tgz"
}