Skip to content

Commit

Permalink
ENH: updated README and added examples file.
Browse files Browse the repository at this point in the history
  • Loading branch information
srossross committed Sep 16, 2013
1 parent edd8e2f commit 07091b5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:'https://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
Expand Down Expand Up @@ -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

```
Expand Down
15 changes: 15 additions & 0 deletions examples/stand-alone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var http = require('http'),
caronte = require('caronte');
//
// Create your proxy server
//
caronte.createProxyServer({target:'https://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);

0 comments on commit 07091b5

Please sign in to comment.