Skip to content
Myr

Added MethodOverride

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

authored by visionmedia · committed by visionmedia · parent db4dcf8 · Browse files · 7 files+28 added−8 removed
This commit

State

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

Diff stats

7 files+28 added−8 removed

  • tests:+17 added−1 removed
  • other:+11 added−7 removed

7 files+28 added−8 removed

modified:examples/app.js+2 added
modified:lib/express/plugins/method-override.js+2 added-2 removed
modified:lib/express/core.js+2 added
239 unmodified lines
240 var body 241 response.headers = {}242 this.request = request, this.response = response243 this.request.uri.path = normalizePath(this.request.uri.path)244 this.request.uri.params = parseNestedParams(this.request.uri.params)245 trigger('request')246 if (typeof (body = Express.router.route(request)) == 'string')247 halt(200, body)248 },249
28 unmodified lines
modified:lib/express/helpers.js+5 added-5 removed
105 unmodified lines
106 return path.slice(path.lastIndexOf('.') + 1)107}108109/**110 * Return a placeholder route param keyed 111 * with the given _key_ or null.110 * Return a param _key_ value or null.111 *112 * @param {string} key113 * @return {string}114 * @api public115 */116117exports.param = function(key) {119 return Express.router.params[key]118 return Express.router.params[key] ||119 Express.server.request.uri.params[key]120}121122/**123 * Set response header _key_ and _val_ or get
99 unmodified lines
223 *224 * @param {hash} params225 * @return {hash}226 * @see parseParams() 227 * @api private227 * @api public228 */229230function parseNestedParams(params) {230var parseNestedParams = exports.parseNestedParams = function(params) {231 var parts, key232 for (key in params)233 if (parts = key.split('['))234 if (parts.length > 1)
40 unmodified lines
modified:spec/spec.helpers.js+8 added
187 unmodified lines
188 get('/product/:name', function(){ return param('name') })189 get('/user/12').body.should.eql '12'190 get('/product/ipod').body.should.eql 'ipod'191 end192 193 it 'should access request.uri.params'194 get('/user', function(){195 return param('page') || 'First page'196 })197 get('/user').body.should.eql 'First page'198 get('/user', { uri: { params: { page: '2' }}}).body.should.eql '2'199 end200 end201end
modified:spec/spec.node.js+1 added
modified:spec/spec.plugins.method-override.js+8 added-1 removed