Skip to content

More events managed by RoutingProxy #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gonzaloruizdevilla opened this issue Oct 25, 2011 · 4 comments
Closed

More events managed by RoutingProxy #139

gonzaloruizdevilla opened this issue Oct 25, 2011 · 4 comments

Comments

@gonzaloruizdevilla
Copy link

I wanted to handle the 'start' event from http-proxy with some code like this one:

var http = require('http'),
    httpProxy = require('http-proxy');

var server = httpProxy.createServer(function (req, res, proxy) {
    proxy.proxyRequest(req, res, {
        host: 'localhost',
        port: 8001
    });

})

server.listen(8000);

server.proxy.on('start',function(req, res, proxy){
    console.log("Do something");
})

To make this work, I had to add to routing-proxy.js line 93:

this.proxies[key].on('start', this.emit.bind(this, 'start'));

I guess that the same should be done with other events (forward)

@desaintmartin
Copy link

Doesn't it work using http.createServer, like in the websocket example?

@coderarity
Copy link
Contributor

Hey, I just made a pull request that fixes this. See #216.

@cronopio
Copy link
Contributor

cronopio commented Jun 5, 2012

@gonzaloruizdevilla @desaintmartin can you test it again against the 0.8.1 version just released today. Should works now.

@gonzaloruizdevilla
Copy link
Author

I've just seen it. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants