Skip to content
Myr

Started Request

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

authored by visionmedia · committed by visionmedia · parent c6cc291 · Browse files · 4 files+76 added−56 removed
This commit

State

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

Diff stats

4 files+76 added−56 removed

  • other:+76 added−56 removed

4 files+76 added−56 removed

modified:lib/express/core.js+3 added-34 removed
2 unmodified lines
34process.mixin(require('sys'))5process.mixin(require('express/exceptions'))6process.mixin(require('express/collection'))7process.mixin(require('express/event'))8process.mixin(require('express/request'))9process.mixin(require('express/helpers'))10process.mixin(require('express/plugin'))11process.mixin(require('express/mime'))12process.mixin(require('express/view'))13process.mixin(require('express/dsl'))1413// --- Helpers1415/**16 * Normalize the given _path_.17 * Strips trailing slashes and whitespace.18 *19 * @param {string} path20 * @return {string}21 * @api private22 */2324function normalizePath(path) {25 return path.replace(/[\s\/]*$/g, '')26}2715// --- Route1617Route = Class({18
191 unmodified lines
210 211 /**212 * Route the given _request_ and _response_.213 *227 * - Defaults response headers to {}228 * - Normalizes the request path to prep for matching routes229 * - Parses urlencoded request bodies230 * - Invokes Express.router.route() to do its job231 * - Responds immediately if the route returns a body string232 *214 * @param {object} request215 * @param {object} response216 * @api private217 */218 219 route: function(request, response){239 var body 240 response.headers = {}, request.params = {}241 request.plugins = $(Express.plugins).map(function(plugin){242 return new plugin.klass(plugin.options) 243 })244 this.request = request, this.response = response245 this.request.uri.path = normalizePath(request.uri.path)246 this.request.uri.params = parseNestedParams(request.uri.params)247 this.request.uri.post = 248 header('content-type') == 'application/x-www-form-urlencoded' ?249 parseParams(request.body) :250 {}251 trigger('request')220 trigger('request', { request: request = new Request(request, response) })221 try {222 if (typeof (body = (new Express.router).route(request)) == 'string')223 halt(200, body)224 }
46 unmodified lines
added:lib/express/event.js+29 added
modified:lib/express/plugin.js-22 removed
added:lib/express/request.js+44 added