Skip to content

Commit

Permalink
[doc] update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Nov 13, 2013
1 parent 54eceb4 commit dcb873a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Expand Up @@ -33,7 +33,6 @@ An object will be returned with four values:

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

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

Errors can be listened on either using the Event Emitter API

```javascript
proxy.on('error', function(e) {
...
});
```

or using the callback API

```javascript
proxy.web(req, res, { target: 'http://mytarget.com:8080' }, function(e) { ... });
```

When a request is proxied it follows two different pipelines ([available here](lib/http-proxy/passes))
which apply transformations to both the `req` and `res` object.
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data
to the client.

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

Expand Down

0 comments on commit dcb873a

Please sign in to comment.