Update the README to describe middleware err handler.

This commit is contained in:
Phil Jackson 2013-09-10 15:17:52 +01:00 committed by indexzero
parent bc12ca3939
commit 25bb3bfa70

View File

@ -441,6 +441,17 @@ A regular request we receive is to support the modification of html/xml content
[Harmon](https://github.com/No9/harmon/) is a stream based middleware plugin that is designed to solve that problem in the most effective way possible.
If you would like to handle errors passed to `next()` then attach a listener to the proxy:
server = httpProxy.createServer(
myMiddleWare,
9000, 'localhost'
).listen(8000);
server.proxy.on('middlewareError', function (err, res, req) {
// handle the error here and call res.end()
});
## Proxying WebSockets
Websockets are handled automatically when using `httpProxy.createServer()`, however, if you supply a callback inside the createServer call, you will need to handle the 'upgrade' proxy event yourself. Here's how: