Skip to content
Myr

add Router.all() method

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

Similar to app.all() but specifically for attaching handlers to all methods under a standalone router. This is useful for isolating routers that require "middleware" like features for all routes managed by the router.

authored by Roman Shtylman · committed by Roman Shtylman · parent 89e7264 · Browse files · 2 files+27 added−0 removed
This commit

State

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

Diff stats

2 files+27 added−0 removed

  • tests:+18 added−0 removed
  • other:+9 added−0 removed

2 files+27 added−0 removed

modified:lib/router/index.js+9 added
300 unmodified lines
301 (this.map[method] = this.map[method] || []).push(route);302 return this;303};304305Router.prototype.all = function(path) {306 var self = this;307 var args = [].slice.call(arguments);308 methods.forEach(function(method){309 self.route.apply(self, [method].concat(args));310 });311 return this;312};313314methods.forEach(function(method){315 Router.prototype[method] = function(path){316 var args = [method].concat([].slice.call(arguments));317 this.route.apply(this, args);
3 unmodified lines
modified:test/Router.js+18 added