Skip to content
Myr

update markdown docs

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 0acee67 · Browse files · 3 files+34 added−44 removed
This commit

State

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

Diff stats

3 files+34 added−44 removed

  • other:+34 added−44 removed

3 files+34 added−44 removed

modified:docs/express.md+17 added-22 removed
218 unmodified lines
219 ## Examples220 221 // Accept: text/html222 req.accepts('html');223 // => "html"223 // => "html"224 225 // Accept: text/*, application/json226 req.accepts('html');227 // => "html"
27 unmodified lines
255# req.param()256257 Return the value of param `name` when present or `defaultValue`.258 259 - Checks body params, ex: id=12, {"id":12}259 - Checks route placeholders, ex: _/user/:id_260 - Checks body params, ex: id=12, {"id":12}261 - Checks query string params, ex: ?id=12262 263 To utilize request bodies, `req.body`264 should be an object. This can be done by using
19 unmodified lines
284 // => true285 286 req.is('html');287 // => false288 289 Now within our route callbacks, we can use to to assert content types290 such as "image/jpeg", "image/png", etc.291 292 app.post('/image/upload', function(req, res, next){293 if (req.is('image/*')) {294 // do something295 } else {296 next();297 }298 });288289290# res291
68 unmodified lines
360 Optionally providing an alternate attachment `filename`,361 and optional callback `fn(err)`. The callback is invoked362 when the data transfer is complete, or when an error has363 ocurred. Be sure to check `res.headerSent` if you plan to respond.364 365 This method uses `res.sendfile()`.366367# res.format()368369 Respond to the Acceptable formats using an `obj`
24 unmodified lines
394 }395 });396 397 In addition to canonicalized MIME types you may407 ## also use extnames mapped to these types398 also use extnames mapped to these types:399 400 res.format({401 text: function(){402 res.send('hey');
4 unmodified lines
407 },408 409 json: function(){410 res.send({ message: 'hey' });420 }411 }412 });413 414 By default Express passes an `Error`415 with a `.status` of 406 to `next(err)`416 if a match is not made, however you may417 provide an optional callback `fn` to418 be invoked instead.419420# res.attachment()421422 Set _Content-Disposition_ header to _attachment_ with optional `filename`.423427# res.set()424# res.set425426 Set header `field` to `val`, or pass430 an object of of header fields.427 an object of header fields.428 429 ## Examples430 431 res.set('Accept', 'application/json');432 res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });433 434 Aliased as `res.header()`.435436# res.get()437438 Get value for header `field`.
1 unmodified line
440# res.clearCookie()441442 Clear cookie `name`.443445# res.signedCookie()446447 Set a signed cookie with the given `name` and `val`.448 See `res.cookie()` for details.449444# res.cookie()445446 Set cookie `name` to `val`, with the given `options`.447 448 ## Options449 450 - `maxAge` max-age in milliseconds, converted to `expires`451 - `signed` sign the cookie452 - `path` defaults to "/"453 454 ## Examples455
51 unmodified lines
modified:docs/request.md+2 added-13 removed
modified:docs/response.md+15 added-9 removed
71 unmodified lines
72 Optionally providing an alternate attachment `filename`,73 and optional callback `fn(err)`. The callback is invoked74 when the data transfer is complete, or when an error has75 ocurred. Be sure to check `res.headerSent` if you plan to respond.76 77 This method uses `res.sendfile()`.7879# res.format()8081 Respond to the Acceptable formats using an `obj`
24 unmodified lines
106 }107 });108 109 In addition to canonicalized MIME types you may108 ## also use extnames mapped to these types110 also use extnames mapped to these types:111 112 res.format({113 text: function(){114 res.send('hey');
4 unmodified lines
119 },120 121 json: function(){122 res.send({ message: 'hey' });121 }123 }124 });125 126 By default Express passes an `Error`127 with a `.status` of 406 to `next(err)`128 if a match is not made, however you may129 provide an optional callback `fn` to130 be invoked instead.131132# res.attachment()133134 Set _Content-Disposition_ header to _attachment_ with optional `filename`.135128# res.set()136# res.set137138 Set header `field` to `val`, or pass131 an object of of header fields.139 an object of header fields.140 141 ## Examples142 143 res.set('Accept', 'application/json');144 res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });145 146 Aliased as `res.header()`.147148# res.get()149150 Get value for header `field`.
1 unmodified line
152# res.clearCookie()153154 Clear cookie `name`.155146# res.signedCookie()147148 Set a signed cookie with the given `name` and `val`.149 See `res.cookie()` for details.150156# res.cookie()157158 Set cookie `name` to `val`, with the given `options`.159 160 ## Options161 162 - `maxAge` max-age in milliseconds, converted to `expires`163 - `signed` sign the cookie164 - `path` defaults to "/"165 166 ## Examples167
51 unmodified lines