@@ -33,7 +33,6 @@ An object will be returned with four values:
33
33
34
34
* web ` req, res, [options] ` (used for proxying regular HTTP(S) requests)
35
35
* 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)
37
36
* listen ` port ` (a function that wraps the object in a webserver, for your convenience)
38
37
39
38
Is it then possible to proxy requests by calling these functions
@@ -44,15 +43,26 @@ require('http').createServer(function(req, res) {
44
43
});
45
44
```
46
45
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
+
47
60
When a request is proxied it follows two different pipelines ([ available here] ( lib/http-proxy/passes ) )
48
61
which apply transformations to both the ` req ` and ` res ` object.
49
62
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
50
63
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data
51
64
to the client.
52
65
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.
56
66
57
67
#### Setup a basic stand-alone proxy server
58
68
0 commit comments