Skip to content

Commit

Permalink
[fix] do not use middleware code if it's not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarr committed Aug 2, 2011
1 parent 6ec8d6c commit 2012588
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ exports.createServer = function () {
switch (typeof arg) {
case 'string': host = arg; break;
case 'number': port = arg; break;
case 'function': middleware.push(arg); break;
case 'function': middleware.push(handler = callback = arg); break;
case 'object': options = arg; break;
};
});
Expand Down Expand Up @@ -203,11 +203,15 @@ exports.createServer = function () {
}
}

if (middleware.length) {
if (middleware.length /*> 1*/) {
//handler = callback = middleware.shift()
//else if (middleware.length)
handler = callback = stack(middleware, proxy);
}
else if (middleware.length) { //do not use middleware code if it's not needed.
var h = middleware[0]
handler = callback = function (req,res) { h(req,res,proxy) };
}

if (!handler) {
//
Expand Down

0 comments on commit 2012588

Please sign in to comment.