Skip to content
Myr

decouple Router options. Closes #941

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 85ea5f6 · Browse files · 2 files+12 added−8 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+12 added−8 removed

  • other:+12 added−8 removed

2 files+12 added−8 removed

modified:lib/router/index.js+9 added-7 removed
25 unmodified lines
2627var methods = exports.methods = require('./methods');2829/**30 * Initialize a new `Router` with the given `app`.30 * Initialize a new `Router` with the given `options`.31 * 32 * @param {express.HTTPServer} app32 * @param {Object} options33 * @api private34 */3536function Router(app) {36function Router(options) {37 options = options || {};38 var self = this;38 this.app = app;39 this.routes = new Collection;40 this.map = {};41 this.params = {};42 this._params = [];43 this.caseSensitive = options.caseSensitive;44 this.strict = options.strict;4546 this.middleware = function(req, res, next){47 self._dispatch(req, res, next);48 };
349 unmodified lines
398 var app = this.app399 , callbacks = utils.flatten([].slice.call(arguments, 2));400401 // ensure path was given400 if (!path) throw new Error('app.' + method + '() requires a path');402 if (!path) throw new Error('Router#' + method + '() requires a path');403404 // create the route405 var route = new Route(method, path, callbacks, {404 sensitive: app.enabled('case sensitive routing')405 , strict: app.enabled('strict routing')406 sensitive: this.caseSensitive407 , strict: this.strict408 });409410 // add it411 (this.map[method] = this.map[method] || []).push(route);
3 unmodified lines
modified:lib/application.js+3 added-1 removed
106 unmodified lines
107 this._router = new Router(this);108 this.routes = this._router.routes;109 this.__defineGetter__('router', function(){110 this._usedRouter = true;111 this._router.caseSensitive = this.enabled('case sensitive routing');112 this._router.strict = this.enabled('strict routing');111 return self._router.middleware;113 return this._router.middleware;114 });115116 // default locals117 this.locals.settings = this.settings;
442 unmodified lines