Skip to content

Commit 07091b5

Browse files
committed
ENH: updated README and added examples file.
1 parent edd8e2f commit 07091b5

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ You can easily add a `pass` (stages) into both the pipelines (XXX: ADD API).
4545

4646
In addition, every stage emits a corresponding event so introspection during the process is always available.
4747

48+
#### Setup a basic stand-alone proxy server
49+
50+
var http = require('http'),
51+
caronte = require('caronte');
52+
//
53+
// Create your proxy server
54+
//
55+
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
56+
57+
//
58+
// Create your target server
59+
//
60+
http.createServer(function (req, res) {
61+
res.writeHead(200, { 'Content-Type': 'text/plain' });
62+
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
63+
res.end();
64+
}).listen(9000);
65+
4866
#### Setup a stand-alone proxy server with custom server logic
4967

5068
``` js
@@ -72,6 +90,17 @@ server.listen(5050);
7290
* Commit to your local branch (which must be different from `master`)
7391
* Submit your Pull Request (be sure to include tests and update documentation)
7492

93+
### Options
94+
95+
`caronte.createProxyServer` supports the following options:
96+
97+
* **target**: <url string to be parsed with the url module>
98+
* **forward**: <url string to be parsed with the url module>
99+
* **ssl**: object to be passed to https.createServer()
100+
* **ws**: true/false, if you want to proxy websockets
101+
* **xfwd**: true/false, adds x-forward headers
102+
* **maxSock**: maximum number of sockets
103+
75104
### Test
76105

77106
```

examples/stand-alone.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var http = require('http'),
2+
caronte = require('caronte');
3+
//
4+
// Create your proxy server
5+
//
6+
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
7+
8+
//
9+
// Create your target server
10+
//
11+
http.createServer(function (req, res) {
12+
res.writeHead(200, { 'Content-Type': 'text/plain' });
13+
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
14+
res.end();
15+
}).listen(9000);

0 commit comments

Comments
 (0)