Skip to content
Myr

Added `app.routes`, replacing `app.routes.all()`. Closes #811

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 0ed74aa · Browse files · 1 file+13 added−13 removed
This commit

State

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

Diff stats

1 file+13 added−13 removed

  • other:+13 added−13 removed

1 file+13 added−13 removed

modified:lib/application.js+13 added-13 removed
49 unmodified lines
5051 // route reflection methods52 methods.forEach(function(method){53 self.lookup[method] = function(path){54 return self.routes.lookup(method, path);54 return self._router.lookup(method, path);55 };5657 self.match[method] = function(path){58 return self.routes.match(method, path);58 return self._router.match(method, path);59 };6061 self.remove[method] = function(path){62 return self.routes.lookup(method, path).remove();62 return self._router.lookup(method, path).remove();63 };64 });6566 // del -> delete
55 unmodified lines
122 next();123 });124125 // router126 this.routes = new Router(this);127 this.routeList = this.routes.routes;126 this._router = new Router(this);127 this.routes = this._router.routes;128 this.__defineGetter__('router', function(){129 this.__usedRouter = true;130 return self.routes.middleware;130 return self._router.middleware;131 });132133 // default locals134 this.locals.settings = this.settings;
12 unmodified lines
147 * @api public148 */149150app.remove = function(path){151 return this.routes.lookup('all', path).remove();151 return this._router.lookup('all', path).remove();152};153154/**155 * Lookup routes defined with a path
4 unmodified lines
160 * @api public161 */162163app.lookup = function(path){164 return this.routes.lookup('all', path);164 return this._router.lookup('all', path);165};166167/**168 * Lookup routes matching the given `url`.
3 unmodified lines
172 * @api public173 */174175app.match = function(url){176 return this.routes.match('all', url);176 return this._router.match('all', url);177};178179/**180 * Proxy `connect.HTTPServer#use()` to apply settings to
163 unmodified lines
344 });345 });346 // param logic347 } else if ('function' == typeof name) {348 this.routes.param(name);348 this._router.param(name);349 // single350 } else {351 if (':' == name[0]) name = name.substr(1);352 fns.forEach(function(fn){353 self.routes.param(name, fn);353 self._router.param(name, fn);354 });355 }356357 return this;
141 unmodified lines
499methods.forEach(function(method){500 app[method] = function(path){501 if ('get' == method && 1 == arguments.length) return this.set(path); 502 var args = [method].concat(toArray(arguments));503 if (!this.__usedRouter) this.use(this.router);504 return this.routes._route.apply(this.routes, args);503 if (!this.__usedRouter) this.use(this._router);504 return this._router._route.apply(this._router, args);505 }506});507508/**
84 unmodified lines