ENH: updated README and added examples file.

This commit is contained in:
srossross 2013-09-16 11:21:20 -07:00
parent edd8e2f04e
commit 07091b5077
2 changed files with 44 additions and 0 deletions

View File

@ -45,6 +45,24 @@ You can easily add a `pass` (stages) into both the pipelines (XXX: ADD API).
In addition, every stage emits a corresponding event so introspection during the process is always available.
#### Setup a basic stand-alone proxy server
var http = require('http'),
caronte = require('caronte');
//
// Create your proxy server
//
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
//
// Create your target server
//
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000);
#### Setup a stand-alone proxy server with custom server logic
``` js
@ -72,6 +90,17 @@ server.listen(5050);
* Commit to your local branch (which must be different from `master`)
* Submit your Pull Request (be sure to include tests and update documentation)
### Options
`caronte.createProxyServer` supports the following options:
* **target**: <url string to be parsed with the url module>
* **forward**: <url string to be parsed with the url module>
* **ssl**: object to be passed to https.createServer()
* **ws**: true/false, if you want to proxy websockets
* **xfwd**: true/false, adds x-forward headers
* **maxSock**: maximum number of sockets
### Test
```

15
examples/stand-alone.js Normal file
View File

@ -0,0 +1,15 @@
var http = require('http'),
caronte = require('caronte');
//
// Create your proxy server
//
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
//
// Create your target server
//
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000);