Skip to content
Myr

Clean up patch to Server#use(), add test case for restoring res#app property.

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

authored by Ben Weaver · committed by Tj Holowaychuk · parent f12baf3 · Browse files · 2 files+21 added−3 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+21 added−3 removed

  • tests:+19 added−1 removed
  • other:+2 added−2 removed

2 files+21 added−3 removed

modified:lib/http.js+2 added-2 removed
154 unmodified lines
155 if (middleware.handle) {156 middleware.route = route;157 handle = function(req, res, next) {158 var origApp = res.app;159 middleware.handle(req, res, next && function() {159 middleware.handle(req, res, function(err) {160 req.app = res.app = origApp;161 return next.apply(this, arguments);161 return next(err);162 });163 };164 }165
312 unmodified lines
modified:test/express.test.js+19 added-1 removed
404 unmodified lines
405 assert.response(app,406 { url: '/regular' },407 { body: 'hey' });408 },409410 'test .app property after returning control to parent': function() {411 var app = express.createServer();412413 // Mounted servers did not restore `req.app` and `res.app` when414 // passing control back to parent via `out()` in `#handle()`.415416 app.use(express.createServer());417418 app.use(function(req, res, next) {419 res.send((res.app === app) ? 'restored' : 'not-restored');420 });421422 assert.response(app,423 { url: '/' },424 { body: 'restored' }425 );426 },427 428 'test route middleware': function(){429 var app = express.createServer();430
120 unmodified lines
551 assert.response(app,552 { url: '/user/12', method: 'OPTIONS' },553 { headers: { Allow: 'GET,PUT' }});554 }537};555};