Skip to content
Myr

Docs

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

authored by visionmedia · committed by visionmedia · parent ba8dffe · Browse files · 1 file+46 added−0 removed
This commit

State

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

Diff stats

1 file+46 added−0 removed

  • other:+46 added−0 removed

1 file+46 added−0 removed

modified:lib/express/core.js+46 added
181 unmodified lines
182183// --- Server184185Server = Class({186 187 /**188 * Default port number.189 */190 191 port: 3000,192 193 /**194 * Default host ip.195 */196 197 host: 'localhost',198 199 /**200 * Run Express at _host_ and _port_, otherwise201 * falling back on the defaults.202 *203 * - Buffers request bodies204 * - Calls #route() once the request is complete205 *206 * @param {string} host207 * @param {int} port208 * @see run()209 * @api private210 */211 212 run: function(host, port){213 var self = this214 if (host) this.host = host215 if (port) this.port = port
4 unmodified lines
220 })221 .listen(this.port, this.host)222 puts('Express started at http://' + this.host + ':' + this.port + '/')223 },224 225 /**226 * Route the given _request_ and _response_.227 *228 * - Defaults response headers to {}229 * - Normalizes the request path to prep for matching routes230 * - Invokes Express.router.route() to do its job231 * - Responds immediately if the route returns a body string232 *233 * @param {object} request234 * @param {object} response235 * @api private236 */237 238 route: function(request, response){239 response.headers = {}240 this.request = request, this.response = response241 this.request.uri.path = normalizePath(this.request.uri.path)242 if (typeof (this.response.body = Express.router.route(request)) == 'string')243 this.respond()244 },245 246 /**247 * Respond immediately with optional _body_.248 *249 * @param {string} body250 * @api private251 */252 253 respond: function(body){254 if (body) this.response.body = body255 this.response.sendHeader(this.response.status || 404, this.response.headers || {})256 this.response.sendBody(this.response.body || '')
13 unmodified lines