Skip to content
Myr

Fixed middleware precedence. Closes #345

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

The first call to app.{get,del,put,post}() will stack the router middleware. This means config can flow naturally BEFORE any routes have been created, preventing breakage of bodyDecoder etc

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

  • tests:+8 added−2 removed
  • other:+5 added−3 removed

2 files+13 added−5 removed

modified:lib/express/server.js+5 added-3 removed
modified:test/express.test.js+8 added-2 removed
205 unmodified lines
206 'test middleware precedence': function(assert){207 var app = express.createServer();208 209 app.use(connect.bodyDecoder());210211 assert.equal(2, app.stack.length);212 213 app.post('/', function(req, res){214 res.send(JSON.stringify(req.body || ''));215 });216 app.get('/', function(){214 217 218 });219 assert.equal(3, app.stack.length);220221 assert.response(app,216 { url: '/', method: 'POST', data: 'name=tj' },222 { url: '/', method: 'POST', data: 'name=tj', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }},223 { body: '{"name":"tj"}' });224 }225};