Skip to content
Myr

Several Request methods are now chainable

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

authored by visionmedia · committed by visionmedia · parent 4ed44c7 · Browse files · 1 file+13 added−4 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+13 added−4 removed

  • other:+13 added−4 removed

1 file+13 added−4 removed

modified:lib/express/request.js+13 added-4 removed
128 unmodified lines
129 /**130 * Set response status to _code_.131 *132 * @param {int} code133 * @return {int}133 * @return {Request)134 * @api public135 */136137 status: function(code) {138 return this.response.status = code138 this.response.status = code139 return this140 },141 142 /**143 * Immediately respond with response _code_, _body_ and optional _encoding_.
41 unmodified lines
185 * Set Content-Type header to the mime type186 * for the given _path_, which calls mime().187 *188 * @param {string} path189 * @return {Request}190 * @see mime()191 * @api public192 */193194 contentType: function(path) {195 this.header('content-type', mime(path))196 return this197 },198 199 /**200 * Trigger even _name_ with optional _data_.201 *202 * @param {string} name203 * @param {hash} data204 * @return {Request}205 * @api public206 */207208 trigger: function(name, data) {
3 unmodified lines
212 })213 this.plugins.each(function(plugin){214 plugin.trigger(new Event(name, data))215 })216 return this217 },218 219 /**220 * Transfer static file at the given _path_ as an attachment.221 *222 * @param {string} path223 * @return {Request}224 * @api public225 */226 227 download: function(path) {222 this.attachment(path)223 this.sendfile(path)228 return this.attachment(path).sendfile(path)229 },230 231 /**232 * Set Content-Disposition header to 'attachment',233 * with optional file _path_.234 *235 * @param {string} path236 * @return {Request}237 * @api public238 */239 240 attachment: function(path) {241 this.header('content-disposition', path ? 242 'attachment; filename="' + path + '"' :243 'attachment')244 return this245 },246 247 /**248 * Transfer static file at the given _path_.249 *250 * @param {string} path251 * @return {Request}252 * @api public253 */254 255 sendfile: function(path) {256 (new StaticFile(path)).send(this)257 return this258 }259})