From c6b7a7919f774d49e5d1d56990e9590e6a12e93c Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Wed, 9 Apr 2014 13:37:27 -0400 Subject: [PATCH] [fix] always be an eventemitter for consistency fixes #606 --- lib/http-proxy.js | 11 +++-------- lib/http-proxy/index.js | 9 ++------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/http-proxy.js b/lib/http-proxy.js index 5df69a9..bea3fe1 100644 --- a/lib/http-proxy.js +++ b/lib/http-proxy.js @@ -8,13 +8,6 @@ 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. * @@ -30,7 +23,9 @@ module.exports.createProxy = function(options) { * @api public */ -module.exports.createProxyServer = module.exports.createServer = function createProxyServer(options) { +module.exports.createProxyServer = + module.exports.createServer = + module.exports.createProxy = function createProxyServer(options) { /* * `options` is needed and it must have the following layout: * diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 9ae6861..01fce24 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -26,15 +26,10 @@ httpProxy.Server = ProxyServer; */ function createRightProxy(type) { - var webPasses = Object.keys(web).map(function(pass) { - return web[pass]; - }); - var wsPasses = Object.keys(ws).map(function(pass) { - return ws[pass]; - }); + return function(options) { return function(req, res /*, [head], [opts] */) { - var passes = (type === 'ws') ? (this.wsPasses || wsPasses) : (this.webPasses || webPasses), + var passes = (type === 'ws') ? this.wsPasses : this.webPasses, args = [].slice.call(arguments), cntr = args.length - 1, head, cbl;