Skip to content
Myr

misc refactoring

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 19e3384 · Browse files · 1 file+6 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

1 file+6 added−8 removed

  • other:+6 added−8 removed

1 file+6 added−8 removed

modified:lib/application.js+6 added-8 removed
163 unmodified lines
164 * Proxy `connect#use()` to apply settings to165 * mounted applications.166 *167 * @param {String|Function|Server} route168 * @param {Function|Server} middleware168 * @param {Function|Server} fn169 * @return {app} for chaining170 * @api public171 */172173app.use = function(route, middleware){173app.use = function(route, fn){174 var app, home, handle;175176 if ('string' != typeof route) {177 middleware = route, route = '/';178 }176 if ('string' != typeof route) fn = route, route = '/';177178 // express app181 if (middleware.handle && middleware.set) app = middleware;179 if (fn.handle && fn.set) app = fn;180181 // restore .app property on req and res182 if (app) {183 app.route = route;186 middleware = function(req, res, next) {184 fn = function(req, res, next) {185 var orig = req.app;186 app.handle(req, res, function(err){187 req.app = res.app = orig;188 next(err);189 });190 };191 }192195 connect.proto.use.call(this, route, middleware);193 connect.proto.use.call(this, route, fn);194195 // mounted an app, invoke the hook196 // and adjust some settings197 if (app) {
392 unmodified lines