Skip to content
Myr

added an array of routes

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

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e0bd0d6 · Browse files · 2 files+13 added−6 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+13 added−6 removed

  • other:+13 added−6 removed

2 files+13 added−6 removed

modified:lib/router/index.js+12 added-6 removed
35 unmodified lines
3637function Router(app) {38 var self = this;39 this.app = app;40 this.routes = {};40 this.routes = new Collection;41 this.map = {};42 this.params = {};43 this._params = [];4445 this.middleware = function(req, res, next){
61 unmodified lines
107 * @api public108 */109110Router.prototype.remove = function(route){110 var routes = this.routes[route.method]111 var routes = this.map[route.method]112 , len = routes.length;113114 // remove from array115 var i = this.routes.indexOf(route);116 this.routes.splice(i, 1);117118 // remove from map119 for (var i = 0; i < len; ++i) {120 if (route == routes[i]) {121 routes.splice(i, 1);122 return true;
52 unmodified lines
175 , route;176177 for (var i = 0; i < len; ++i) {178 method = methods[i];173 routes = this.routes[method];179 routes = this.map[method];180 if (!routes) continue;181 for (var j = 0, jlen = routes.length; j < jlen; ++j) {182 route = routes[j];183 if (fn(route)) ret.push(route);
150 unmodified lines
334Router.prototype._match = function(req, i){335 var method = req.method.toLowerCase()336 , url = parse(req.url)337 , path = url.pathname332 , routes = this.routes338 , routes = this.map339 , captures340 , route341 , keys;342
54 unmodified lines
397 , strict: app.enabled('strict routing')398 });399400 // add it395 (this.routes[method] = this.routes[method] || [])396 .push(route);401 (this.map[method] = this.map[method] || []).push(route);402 this.routes.push(route);403 return this;404};
modified:lib/application.js+1 added
122 unmodified lines
123 });124125 // router126 this.routes = new Router(this);127 this.routeList = this.routes.routes;128 this.__defineGetter__('router', function(){129 this.__usedRouter = true;130 return self.routes.middleware;131 });
461 unmodified lines