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
Provenance
- Commit
a52845e- Tree
7ca224e- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
e7e2c4e
4 files changed+15 added−14 removed
modified:lib/express/plugins/body-decoder.js+3 added-5 removed
10 unmodified lines11121314151617181915161718192010 unmodified lines */ request: function(event) { var request = event.request request.uri.post = request.header('content-type') && request.header('content-type').indexOf('application/x-www-form-urlencoded') > -1 ? parseParams(request.body) : {} if (request.header('content-type') && request.header('content-type').indexOf('application/x-www-form-urlencoded') > -1) request.params.post = parseParams(request.body) } }})No newline at end of fileNo newline at end of filemodified:lib/express/collection.js+1 added-1 removed
44 unmodified lines45 * @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 linesmodified:lib/express/core.js+2 added-2 removed
153 unmodified lines154 }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 private1 unmodified line164 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 linesmodified:lib/express/request.js+9 added-6 removed
91 unmodified lines92 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 lines123 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} key1 unmodified line133 * @api public134 */135 136 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 type95 unmodified lines