Commit da55777a authored by indexzero's avatar indexzero

[api] Corrected chain of argument passing

parent 5d94ae27
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
var sys = require('sys'), var sys = require('sys'),
colors = require('colors') colors = require('colors')
http = require('http'), http = require('http'),
httpProxy = require('http-proxy').HttpProxy; httpProxy = require('./lib/node-http-proxy');
// ascii art from http://github.com/marak/asciimo // ascii art from http://github.com/marak/asciimo
var welcome = '\ var welcome = '\
...@@ -40,13 +40,13 @@ var welcome = '\ ...@@ -40,13 +40,13 @@ var welcome = '\
sys.puts(welcome.rainbow.bold); sys.puts(welcome.rainbow.bold);
// create regular http proxy server // create regular http proxy server
httpProxy.createServer('localhost', '9000').listen(8000); httpProxy.createServer('localhost', 9000).listen(8000);
sys.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow); sys.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
// http proxy server with latency // http proxy server with latency
httpProxy.createServer(function (req, res, proxy){ httpProxy.createServer(function (req, res, proxy){
setTimeout(function(){ setTimeout(function(){
proxy.proxyRequest('localhost', '9000', req, res); proxy.proxyRequest('localhost', 9000, req, res);
}, 200) }, 200)
}).listen(8001); }).listen(8001);
sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with latency'.magenta.underline ); sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with latency'.magenta.underline );
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
var sys = require('sys'), var sys = require('sys'),
eyes = require('eyes'),
http = require('http'), http = require('http'),
events = require('events'); events = require('events');
...@@ -37,7 +38,7 @@ exports.HttpProxy = function () { ...@@ -37,7 +38,7 @@ exports.HttpProxy = function () {
exports.createServer = function () { exports.createServer = function () {
// Initialize the nodeProxy to start proxying requests // Initialize the nodeProxy to start proxying requests
var proxy = new (exports.HttpProxy); var proxy = new (exports.HttpProxy);
return proxy.createServer(arguments); return proxy.createServer.apply(proxy, arguments);
}; };
exports.HttpProxy.prototype = { exports.HttpProxy.prototype = {
...@@ -51,18 +52,17 @@ exports.HttpProxy.prototype = { ...@@ -51,18 +52,17 @@ exports.HttpProxy.prototype = {
}, },
createServer: function () { createServer: function () {
var args = Array.prototype.slice.call(arguments), var self = this,
self = this,
server, server,
port, port,
callback; callback;
if (typeof(args[0]) === "function") { if (typeof(arguments[0]) === "function") {
callback = args[0]; callback = arguments[0];
} }
else { else {
server = args[0]; server = arguments[0];
port = args[1]; port = arguments[1];
} }
var proxyServer = http.createServer(function (req, res){ var proxyServer = http.createServer(function (req, res){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment