Skip to content
Myr

request response event is now fired in reverse.

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

This does a few things: a. Allows plugins such as Logger to properly "wrap" all other plugins when it is the first passed to use(). b. Lessons the chance of a plugin failure effecting another plugin

authored by visionmedia · committed by visionmedia · parent 7550dec · Browse files · 3 files+11 added−6 removed
This commit

State

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

Diff stats

3 files+11 added−6 removed

  • other:+11 added−6 removed

3 files+11 added−6 removed

modified:examples/chat/app.js+1 added-1 removed
modified:lib/express/core.js+1 added-1 removed
285 unmodified lines
286 try {287 if (err) throw err288 if (request.response.finished) return289 if (typeof (body = (new Router(request)).route()) === 'string')290 request.halt(200, body, function(err){290 request.halt(200, body, null, function(err){291 if (err) self.error(err, request)292 }) 293 } catch (err) {294 self.error(err, request)
61 unmodified lines
modified:lib/express/request.js+9 added-4 removed
182 unmodified lines
183 // TODO: use exception handler here184 self.response.writeHeader(self.response.status, self.response.headers)185 self.response.write(self.response.body, encoding)186 self.response.close()187 })187 }, true)188 },189 190 /**191 * Pass control to the next matching route, or
31 unmodified lines
223 *224 * @param {string} name225 * @param {object} data226 * @param {function} callback227 * @param {bool} reverse228 * @return {Request}229 * @api public230 */231231 trigger: function(name, data, callback) { 232 trigger: function(name, data, callback, reverse) { 233 if (data instanceof Function)234 reverse = callback,235 callback = data,236 data = null237 data = data || {}238 data.merge({ request: this, response: this.response })239 var self = this,240 complete = 0,239 total = this.plugins.length241 total = this.plugins.length,242 plugins = reverse243 ? self.plugins.reverse()244 : self.plugins245 ;(function next(err) {246 if (err || complete === total)247 callback(err)248 else {244 if (self.plugins.at(complete++).trigger(new Event(name, data), next) !== true)249 if (plugins.at(complete++).trigger(new Event(name, data), next) !== true)250 next()251 }252 })()253 return this
31 unmodified lines