Merge pull request #551 from nodejitsu/caronte

Caronte
This commit is contained in:
yawnt 2014-01-16 07:25:15 -08:00
commit d4942e52e7
3 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,13 @@ var http = require('http'),
*/
module.exports = httpProxy.Server;
module.exports.createProxy = function(options) {
return {
web: httpProxy.createRightProxy('web')(options),
ws: httpProxy.createRightProxy('ws')(options)
};
}
/**
* Creates the proxy server.
*

View File

@ -80,7 +80,7 @@ function createRightProxy(type) {
};
};
}
httpProxy.createRightProxy = createRightProxy;
function ProxyServer(options) {
EE3.call(this);
@ -96,6 +96,10 @@ function ProxyServer(options) {
this.wsPasses = Object.keys(ws).map(function(pass) {
return ws[pass];
});
this.on('error', function(err) {
console.log(err);
});
}
require('util').inherits(ProxyServer, EE3);

View File

@ -117,7 +117,7 @@ web_o = Object.keys(web_o).map(function(pass) {
(options.buffer || req).pipe(proxyReq);
proxyReq.on('response', function(proxyRes) {
server.emit('proxyRes', proxyRes);
if(server) { server.emit('proxyRes', proxyRes); }
for(var i=0; i < web_o.length; i++) {
if(web_o[i](req, res, proxyRes)) { break; }
}