Commit 20125889 authored by Dominic Tarr's avatar Dominic Tarr

[fix] do not use middleware code if it's not needed

parent 6ec8d6ca
......@@ -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;
};
});
......@@ -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) {
//
......
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