Skip to content
Myr

Better naming for param origins [#85]

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

Now Request#params.{get,post,path}

authored by visionmedia · committed by visionmedia · parent e7e2c4e · Browse files · 4 files+15 added−14 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+15 added−14 removed

  • other:+15 added−14 removed

4 files+15 added−14 removed

modified:lib/express/plugins/body-decoder.js+3 added-5 removed
modified:lib/express/collection.js+1 added-1 removed
44 unmodified lines
45 * @api private46 */47 48 init: function(arr) {49 this.arr = arr49 this.arr = arr || []50 },51 52 /**53 * Return the value of _index_ or null.
476 unmodified lines
modified:lib/express/core.js+2 added-2 removed
153 unmodified lines
154 }155 },156 157 /**158 * Map #request.captures to #request.params based on the158 * Map #request.captures to #request.params.path based on the159 * given _route_ keys.160 *161 * @param {Route} route162 * @api private
1 unmodified line
164 165 mapParams: function(route) {166 var self = this167 $(route.keys).each(function(key, i){168 self.request.params[key] = self.request.captures[++i]168 self.request.params.path[key] = self.request.captures[++i]169 })170 }171})172
98 unmodified lines
modified:lib/express/request.js+9 added-6 removed
91 unmodified lines
92 93 init: function(request, response) {94 process.mixin(true, this, request)95 response.headers = {}96 this.params = {}96 this.response = response97 this.uri.path = exports.normalizePath(this.uri.path)99 this.uri.params = parseNestedParams(this.uri.params)98 this.params = { 99 get: parseNestedParams(this.uri.params), 100 post: {}, 101 path: {}102 }103 this.plugins = $(Express.plugins).map(function(plugin){104 return new plugin.klass(plugin.options) 105 })106 },
16 unmodified lines
123 124 /**125 * Return a param _key_ value or null.126 *124 * - Checks route populated parameters127 * - Checks route populated path parameters128 * - Checks POST parameters129 * - Checks GET parameters130 *131 * @param {string} key
1 unmodified line
133 * @api public134 */135136 param: function(key) {134 return this.params[key] ||135 this.uri.post[key] ||136 this.uri.params[key]137 return this.params.get[key] ||138 this.params.post[key] ||139 this.params.path[key]140 },141 142 /**143 * Check if Accept header includes the mime type
95 unmodified lines