Skip to content

Commit dcb873a

Browse files
committed
[doc] update README.md
1 parent 54eceb4 commit dcb873a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ An object will be returned with four values:
3333

3434
* web `req, res, [options]` (used for proxying regular HTTP(S) requests)
3535
* ws `req, socket, head, [options]` (used for proxying WS(S) requests)
36-
* ee (an EventEmitter2 that emits events, you can hook into them to customize behaviour)
3736
* listen `port` (a function that wraps the object in a webserver, for your convenience)
3837

3938
Is it then possible to proxy requests by calling these functions
@@ -44,15 +43,26 @@ require('http').createServer(function(req, res) {
4443
});
4544
```
4645

46+
Errors can be listened on either using the Event Emitter API
47+
48+
```javascript
49+
proxy.on('error', function(e) {
50+
...
51+
});
52+
```
53+
54+
or using the callback API
55+
56+
```javascript
57+
proxy.web(req, res, { target: 'http://mytarget.com:8080' }, function(e) { ... });
58+
```
59+
4760
When a request is proxied it follows two different pipelines ([available here](lib/http-proxy/passes))
4861
which apply transformations to both the `req` and `res` object.
4962
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
5063
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data
5164
to the client.
5265

53-
You can easily add a `pass` (stages) into both the pipelines (XXX: ADD API).
54-
55-
In addition, every stage emits a corresponding event so introspection during the process is always available.
5666

5767
#### Setup a basic stand-alone proxy server
5868

0 commit comments

Comments
 (0)