Skip to content
Myr

More request specific refactoring

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

authored by visionmedia · committed by visionmedia · parent a499d15 · Browse files · 5 files+28 added−26 removed
This commit

State

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

Diff stats

5 files+28 added−26 removed

  • other:+28 added−26 removed

5 files+28 added−26 removed

modified:lib/express/pages/not-found.js+3 added-4 removed
modified:lib/express/pages/show-exceptions.js+2 added-2 removed
modified:lib/express/plugins/common-logger.js+1 added-1 removed
modified:lib/express/core.js+2 added-18 removed
119 unmodified lines
120 var route = this.matchingRoute()121 if (route)122 return route.run(this.request.captures.slice(1))123 else if (this.request.accepts('html') && set('helpful 404'))124 this.request.halt(404, require('express/pages/not-found').render())124 this.request.halt(404, require('express/pages/not-found').render(this.request))125 else126 this.request.halt()127 },128
105 unmodified lines
234 catch (e) {235 if (e instanceof ExpressError)236 throw e237 if (request.accepts('html') && set('show exceptions'))238 request.halt(500, require('express/pages/show-exceptions').render(e))238 request.halt(500, require('express/pages/show-exceptions').render(request, e))239 else240 request.halt(500)241 if (set('throw exceptions'))242 throw e243 }244 },245 246 /**247 * Respond immediately with optional _body_.248 *249 * @param {string} body250 * @api private251 */252 253 respond: function(body){254 this.response.body = body, trigger('response')255 if (typeof this.response.body != 'string') throw new InvalidResponseBody(this.request)256 if (typeof this.response.status != 'number') throw new InvalidStatusCode(this.response.status)257 this.response.sendHeader(this.response.status, this.response.headers)258 this.response.sendBody(this.response.body)259 this.response.finish()244 }245})246247// --- Express
15 unmodified lines
modified:lib/express/request.js+20 added-1 removed
177 unmodified lines
178179 halt: function(code, body) {180 this.status(code = code || 404)181 if (body = body || statusBodies[code])182 return Express.server.respond(body)182 return this.respond(body)183 throw new InvalidStatusCode(code)184 },185 186 /**187 * Respond with _body_.188 *189 * @param {Type} Var190 * @return {Type}191 * @see Request#halt()192 * @api private193 */194 195 respond: function(body) {196 this.response.body = body197 this.trigger('response')198 if (typeof this.response.body != 'string') throw new InvalidResponseBody(this)199 if (typeof this.response.status != 'number') throw new InvalidStatusCode(this.response.status)200 this.response.sendHeader(this.response.status, this.response.headers)201 this.response.sendBody(this.response.body)202 this.response.finish()203 },204 205 /**206 * Set Content-Type header to the mime type207 * for the given _path_, which calls mime().208 *209 * @param {string} path
26 unmodified lines