Skip to content
Myr

support arrays as middleware arguments to .VERB and .all

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Express 3.x supported passing in arrays for sets of common middleware. While there are better ways to do this, removing this feature causes headache in upgrading for no real gain. We can support it without much more code.

authored by Roman Shtylman · committed by Roman Shtylman · parent 6b19e3d · Browse files · 3 files+50 added−43 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+50 added−43 removed

  • other:+50 added−43 removed

3 files+50 added−43 removed

modified:lib/router/index.js+3 added-2 removed
373 unmodified lines
374};375376// create Router#VERB functions377methods.concat('all').forEach(function(method){378 proto[method] = function(path, fn){379 this.route(path)[method](fn);378 proto[method] = function(path){379 var route = this.route(path)380 route[method].apply(route, [].slice.call(arguments, 1));381 return this;382 };383});384
modified:lib/router/route.js+44 added-34 removed
modified:lib/application.js+3 added-7 removed
401 unmodified lines
402403 this.lazyrouter();404405 var route = this._router.route(path);406 for (var i=1 ; i<arguments.length ; ++i) {407 route[method](arguments[i]);408 }406 route[method].apply(route, [].slice.call(arguments, 1));407 return this;408 };409});410
10 unmodified lines
421app.all = function(path){422 this.lazyrouter();423424 var route = this._router.route(path);427 var args = arguments;425 var args = [].slice.call(arguments, 1);426 methods.forEach(function(method){429 for (var i=1 ; i<args.length ; ++i) {430 route[method](args[i]);431 }427 route[method].apply(route, args);428 });429430 return this;431};
101 unmodified lines