Skip to content
Myr

Added Express.server.callback

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

authored by visionmedia · committed by visionmedia · parent 2852524 · Browse files · 2 files+32 added−16 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+32 added−16 removed

  • tests:+6 added−0 removed
  • other:+26 added−16 removed

2 files+32 added−16 removed

modified:lib/express.core.js+26 added-16 removed
88 unmodified lines
89 * @api public90 */91 92 start : function(port, host) {93 this.server.listen(port || 3000, host, function(request, response){94 Express.response.body = null95 Express.response.status = 20096 Express.request = request97 request.headers = Express.arrayToHash(request.headers)98 Express.hook('request', request, response)99 request.uri.params = Express.parseNestedParams(request.uri.params)100 request.uri.path = Express.normalizePath(request.uri.path)101 try { Express.response.body = Express.callRouteFor(request) }102 catch (e) { Express.fail(e) }103 Express.prepareCookie()104 Express.hook('response', Express.request, Express.response)105 response.sendHeader(Express.response.status, Express.hashToArray(Express.response.headers))106 response.sendBody(Express.response.body || '')107 response.finish()108 })93 this.server.listen(port || 3000, host, this.server.callback)94 },95 96 server : {97
8 unmodified lines
106 107 listen : function(port, host, callback) {108 node.http.createServer(callback).listen(port, host)109 puts('Express started at http://' + (host || '127.0.0.1') + ':' + port + '/')110 },111 112 /**113 * Request callback.114 *115 * @param {object} request116 * @param {object} response117 * @api private118 */119 120 callback : function(request, response){121 Express.response.body = null122 Express.response.status = 200123 Express.request = request124 request.headers = Express.arrayToHash(request.headers)125 Express.hook('request', request, response)126 request.uri.params = Express.parseNestedParams(request.uri.params)127 request.uri.path = Express.normalizePath(request.uri.path)128 try { Express.response.body = Express.callRouteFor(request) }129 catch (e) { Express.fail(e) }130 Express.prepareCookie()131 Express.hook('response', Express.request, Express.response)132 response.sendHeader(Express.response.status, Express.hashToArray(Express.response.headers))133 response.sendBody(Express.response.body || '')134 response.finish()135 }136 },137 138 /**
469 unmodified lines
modified:spec/spec.routing.js+6 added