Updated 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 f60bcca · Browse files · 7 files·+121 added−118 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+121 added−118 removed
- other:+121 added−118 removed
Provenance
- Commit
d691ecb- Tree
4c78362- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
f60bcca
7 files changed+121 added−118 removed
modified:docs/api.html+46 added-48 removed
262 unmodified lines263 </td>264 <td class="code">265 <pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">param</span> = <span class="keyword">function</span>(<span class="variable">name</span>){266 <span class="comment">// Route params like /user/:id</span>267- <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>.<span class="variable">path</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {268- <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>.<span class="variable">path</span>[<span class="variable">name</span>]; 267+ <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {268+ <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>[<span class="variable">name</span>]; 269 }270 <span class="comment">// Query string params</span>271- <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">params</span>.<span class="variable">get</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {272- <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">params</span>.<span class="variable">get</span>[<span class="variable">name</span>]; 271+ <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">query</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {272+ <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">query</span>[<span class="variable">name</span>]; 273 }274 <span class="comment">// Request body params via connect.bodyDecoder</span>275 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">body</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="this">this</span>.<span class="variable">body</span>[<span class="variable">name</span>] !== <span class="variable">undefined</span>) {276 <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">body</span>[<span class="variable">name</span>];59 unmodified lines336 <td class="code">337 <pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'isXMLHttpRequest'</span>, <span class="variable">isxhr</span>);338 <span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'xhr'</span>, <span class="variable">isxhr</span>);</code></pre>339 </td>340+</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">341+<td class="docs">342+<p>Parse mini markdown implementation.343+The following conversions are supported,344+primarily for the "flash" middleware:</p>345+346+<p> <em>foo</em> or <em>foo</em> become <em>foo</em>347+ <strong>foo</strong> or <strong>foo</strong> become <strong>foo</strong>348+ <a href="B">A</a> becomes <a href="B">A</a></p>349+350+<h2></h2>351+352+<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>353+</td>354+<td class="code">355+<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){356+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)357+ .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'<strong>$2</strong>'</span>)358+ .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'<em>$2</em>'</span>)359+ .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'<a href="$2">$1</a>'</span>);360+};</code></pre>361+</td>362+</tr>363+<tr class="code">364+<td class="docs">365+<p>Escape special characters in the given string of html.</p>366+367+<h2></h2>368+369+<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>370+</td>371+<td class="code">372+<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {373+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)374+ .<span class="variable">replace</span>(<span class="regexp">/&/g</span>, <span class="string">'&'</span>)375+ .<span class="variable">replace</span>(<span class="regexp">/"/g</span>, <span class="string">'"'</span>)376+ .<span class="variable">replace</span>(<span class="regexp">/</g</span>, <span class="string">'<'</span>)377+ .<span class="variable">replace</span>(<span class="regexp">/>/g</span>, <span class="string">'>'</span>);378+};</code></pre>379+</td>380 </tr><tr class="filename"><td><h2 id="lib/express/response.js"><a href="#">response</a></h2></td><td>lib/express/response.js</td></tr><tr class="code">381 <td class="docs">382 <p>Module dependencies.383 </p>276 unmodified lines660 <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'env'</span>, <span class="variable">process</span>.<span class="variable">env</span>.<span class="class">EXPRESS_ENV</span> || <span class="variable">process</span>.<span class="variable">connectEnv</span>.<span class="variable">name</span>);661 662 <span class="comment">// Expose objects to each other</span>663 <span class="this">this</span>.<span class="variable">use</span>(<span class="keyword">function</span>(<span class="variable">req</span>, <span class="variable">res</span>, <span class="variable">next</span>){624- <span class="variable">req</span>.<span class="variable">params</span> = <span class="variable">req</span>.<span class="variable">params</span> || {};625- <span class="variable">req</span>.<span class="variable">params</span>.<span class="variable">get</span> = {};664+ <span class="variable">req</span>.<span class="variable">query</span> = {};665 <span class="variable">res</span>.<span class="variable">headers</span> = {};666 <span class="variable">req</span>.<span class="variable">app</span> = <span class="variable">res</span>.<span class="variable">app</span> = <span class="variable">self</span>;667 <span class="variable">req</span>.<span class="variable">res</span> = <span class="variable">res</span>;668 <span class="variable">res</span>.<span class="variable">req</span> = <span class="variable">req</span>;669 <span class="variable">req</span>.<span class="variable">next</span> = <span class="variable">next</span>;670 <span class="comment">// Assign req.params.get</span>671 <span class="keyword">if</span> (<span class="variable">req</span>.<span class="variable">url</span>.<span class="variable">indexOf</span>(<span class="string">'?'</span>) &<span class="variable">gt</span>; <span class="number integer">0</span>) {633- <span class="comment">// TODO: consider simple substr to increase performance</span>672 <span class="keyword">var</span> <span class="variable">query</span> = <span class="variable">url</span>.<span class="variable">parse</span>(<span class="variable">req</span>.<span class="variable">url</span>).<span class="variable">query</span>;635- <span class="variable">req</span>.<span class="variable">params</span>.<span class="variable">get</span> = <span class="variable">queryString</span>.<span class="variable">parse</span>(<span class="variable">query</span>);673+ <span class="variable">req</span>.<span class="variable">query</span> = <span class="variable">queryString</span>.<span class="variable">parse</span>(<span class="variable">query</span>);674 }675 <span class="variable">next</span>();676 });677 236 unmodified lines914 <span class="keyword">return</span> <span class="variable">arguments</span>.<span class="variable">callee</span>;915 })(<span class="string">'get'</span>)(<span class="string">'post'</span>)(<span class="string">'put'</span>)(<span class="string">'del'</span>);916 </code></pre>917 </td>880-</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">881-<td class="docs">882-<p>Parse mini markdown implementation.883-The following conversions are supported,884-primarily for the "flash" middleware:</p>885-886-<p> <em>foo</em> or <em>foo</em> become <em>foo</em>887- <strong>foo</strong> or <strong>foo</strong> become <strong>foo</strong>888- <a href="B">A</a> becomes <a href="B">A</a></p>889-890-<h2></h2>891-892-<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>893-</td>894-<td class="code">895-<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){896- <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)897- .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'<strong>$2</strong>'</span>)898- .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'<em>$2</em>'</span>)899- .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'<a href="$2">$1</a>'</span>);900-};</code></pre>901-</td>902-</tr>903-<tr class="code">904-<td class="docs">905-<p>Escape special characters in the given string of html.</p>906-907-<h2></h2>908-909-<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>910-</td>911-<td class="code">912-<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {913- <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)914- .<span class="variable">replace</span>(<span class="regexp">/&/g</span>, <span class="string">'&'</span>)915- .<span class="variable">replace</span>(<span class="regexp">/"/g</span>, <span class="string">'"'</span>)916- .<span class="variable">replace</span>(<span class="regexp">/</g</span>, <span class="string">'<'</span>)917- .<span class="variable">replace</span>(<span class="regexp">/>/g</span>, <span class="string">'>'</span>);918-};</code></pre>919-</td>918 </tr><tr class="filename"><td><h2 id="lib/express/view.js"><a href="#">view</a></h2></td><td>lib/express/view.js</td></tr><tr class="code">919 <td class="docs">920 <p>Module dependencies.921 </p>231 unmodified linesmodified:docs/guide.1+18 added-17 removed
148 unmodified lines149 .150 .IP "" 0151 .152 .SS "Routing"153-Express utilizes the HTTP verbs to provide a meaningful, expressive routing API\. For example we may want to render a user\'s account for the path \fI/user/12\fR, this can be done by defining the route below\. The values associated to the named placeholders, are passed as the \fIthird\fR argument, which here we name \fIparams\fR\.153+Express utilizes the HTTP verbs to provide a meaningful, expressive routing API\. For example we may want to render a user\'s account for the path \fI/user/12\fR, this can be done by defining the route below\. The values associated to the named placeholders are available as \fBreq\.params\fR\.154 .155 .IP "" 4156 .157 .nf158 159-app\.get(\'/user/:id\', function(req, res, params){160- res\.send(\'user \' + params\.id);159+app\.get(\'/user/:id\', function(req, res){160+ res\.send(\'user \' + req\.params\.id);161 });162 .163 .fi164 .12 unmodified lines177 .178 .IP "" 0179 .180 .P181-Regular expression literals may also be passed for complex uses\. Since capture groups with literal \fIRegExp\fR\'s are anonymous we can access them directly from the \fIparams\fR array\.181+Regular expression literals may also be passed for complex uses\. Since capture groups with literal \fIRegExp\fR\'s are anonymous we can access them directly \fBreq\.params\fR\.182 .183 .IP "" 4184 .185 .nf186 187-app\.get(/^\\/users?(?:\\/(\\d+)(?:\\\.\\\.(\\d+))?)?/, function(req, res, params){188- res\.send(params);187+app\.get(/^\\/users?(?:\\/(\\d+)(?:\\\.\\\.(\\d+))?)?/, function(req, res){188+ res\.send(req\.params);189 });190 .191 .fi192 .58 unmodified lines251 .252 .IP "" 0253 .254 .SS "Passing Route Control"255-We may pass control to the next \fImatching\fR route, by calling the \fIfourth\fR parameter, the \fInext()\fR function\. When a match cannot be made, control is passed back to Connect\.255+We may pass control to the next \fImatching\fR route, by calling the \fIthird\fR argument, the \fInext()\fR function\. When a match cannot be made, control is passed back to Connect, and middleware continue to be invoked\.256 .257 .IP "" 4258 .259 .nf260 261-app\.get(\'/users/:id?\', function(req, res, params){262- if (params\.id) {261+app\.get(\'/users/:id?\', function(req, res){262+ var id = req\.params\.id;263+ if (id) {264 // do something265 } else {266 next();267 }268 });269 269-app\.get(\'/users\', function(req, res, params){270+app\.get(\'/users\', function(req, res){271 // do something else272 });273 .274 .fi312 unmodified lines587 .SS "req\.param(name)"588 Return the value of param \fIname\fR when present\.589 .590 .IP "\(bu" 4590-Checks route placeholders, ex: /user/:id591+Checks route placeholders (\fIreq\.params\fR), ex: /user/:id592 .593 .IP "\(bu" 4593-Checks query string params, ex: ?id=12594+Checks query string params (\fIreq\.query\fR), ex: ?id=12595 .596 .IP "\(bu" 4596-Checks urlencoded body params, ex: id=12597+Checks urlencoded body params (\fIreq\.body\fR), ex: id=12598 .599 .IP "" 0600 .601 .P361 unmodified lines963 .IP "" 4964 .965 .nf966 966-app\.redirect(\'comments\', function(req, res, params){967- return \'/post/\' + params\.id + \'/comments\';967+app\.redirect(\'comments\', function(req, res){968+ return \'/post/\' + req\.params\.id + \'/comments\';969 });970 .971 .fi972 .59 unmodified lines1032 .1033 .IP "" 01034 .1035 .SS "app\.dynamicHelpers(obj)"1035-Registers dynamic view helpers\. Dynamic view helpers are simply functions which accept \fIreq\fR, \fIres\fR, and \fIparams\fR, and are evaluated against the \fIServer\fR instance before a view is rendered\. The \fIreturn value\fR of this function becomes the local variable it is associated with\.1036+Registers dynamic view helpers\. Dynamic view helpers are simply functions which accept \fIreq\fR, \fIres\fR, and are evaluated against the \fIServer\fR instance before a view is rendered\. The \fIreturn value\fR of this function becomes the local variable it is associated with\.1037 .1038 .IP "" 41039 .1040 .nf1041 1042 app\.dynamicHelpers({1042- session: function(req, res, params){1043+ session: function(req, res){1044 return req\.session;1045 }1046 });1047 .86 unmodified linesmodified:docs/guide.html+21 added-19 removed
327 unmodified lines328 <h3 id="Routing">Routing</h3>329 330 <p>Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.331 For example we may want to render a user's account for the path <em>/user/12</em>, this332-can be done by defining the route below. The values associated to the named placeholders,333-are passed as the <em>third</em> argument, which here we name <em>params</em>.</p>332+can be done by defining the route below. The values associated to the named placeholders333+are available as <code>req.params</code>.</p>334 335-<pre><code>app.get('/user/:id', function(req, res, params){336- res.send('user ' + params.id);335+<pre><code>app.get('/user/:id', function(req, res){336+ res.send('user ' + req.params.id);337 });338 </code></pre>339 340 <p>A route is simple a string which is compiled to a <em>RegExp</em> internally. For example2 unmodified lines343 <pre><code>\/user\/([^\/]+)\/?344 </code></pre>345 346 <p>Regular expression literals may also be passed for complex uses. Since capture347-groups with literal <em>RegExp</em>'s are anonymous we can access them directly from the <em>params</em> array.</p>347+groups with literal <em>RegExp</em>'s are anonymous we can access them directly <code>req.params</code>.</p>348 349-<pre><code>app.get(/^\/users?(?:\/(\d+)(?:\.\.(\d+))?)?/, function(req, res, params){350- res.send(params);349+<pre><code>app.get(/^\/users?(?:\/(\d+)(?:\.\.(\d+))?)?/, function(req, res){350+ res.send(req.params);351 });352 </code></pre>353 354 <p>Curl requests against the previously defined route:</p>41 unmodified lines396 </code></pre>397 398 <h3 id="Passing-Route-Control">Passing Route Control</h3>399 400-<p>We may pass control to the next <em>matching</em> route, by calling the <em>fourth</em> parameter,401-the <em>next()</em> function. When a match cannot be made, control is passed back to Connect.</p>400+<p>We may pass control to the next <em>matching</em> route, by calling the <em>third</em> argument,401+the <em>next()</em> function. When a match cannot be made, control is passed back to Connect,402+and middleware continue to be invoked.</p>403 403-<pre><code>app.get('/users/:id?', function(req, res, params){404- if (params.id) {404+<pre><code>app.get('/users/:id?', function(req, res){405+ var id = req.params.id;406+ if (id) {407 // do something408 } else {409 next();410 }411 });412 411-app.get('/users', function(req, res, params){413+app.get('/users', function(req, res){414 // do something else415 });416 </code></pre>417 201 unmodified lines619 620 <p>Return the value of param <em>name</em> when present.</p>621 622 <ul>621-<li>Checks route placeholders, ex: /user/:id</li>622-<li>Checks query string params, ex: ?id=12</li>623-<li>Checks urlencoded body params, ex: id=12</li>623+<li>Checks route placeholders (<em>req.params</em>), ex: /user/:id</li>624+<li>Checks query string params (<em>req.query</em>), ex: ?id=12</li>625+<li>Checks urlencoded body params (<em>req.body</em>), ex: id=12</li>626 </ul>627 628 629 <p>To utilize urlencoded request bodies, <em>req.body</em>235 unmodified lines865 <p> res.redirect('google');</p>866 867 <p>We may also map dynamic redirects:</p>868 867-<pre><code>app.redirect('comments', function(req, res, params){868- return '/post/' + params.id + '/comments';869+<pre><code>app.redirect('comments', function(req, res){870+ return '/post/' + req.params.id + '/comments';871 });872 </code></pre>873 874 <p>So now we may do the following, and the redirect will dynamically adjust to35 unmodified lines910 911 <h3 id="app-dynamicHelpers-obj-">app.dynamicHelpers(obj)</h3>912 913 <p>Registers dynamic view helpers. Dynamic view helpers912-are simply functions which accept <em>req</em>, <em>res</em>, and <em>params</em>, and are914+are simply functions which accept <em>req</em>, <em>res</em>, and are915 evaluated against the <em>Server</em> instance before a view is rendered. The <em>return value</em> of this function916 becomes the local variable it is associated with.</p>917 918 <pre><code>app.dynamicHelpers({917- session: function(req, res, params){919+ session: function(req, res){920 return req.session;921 }922 });923 </code></pre>53 unmodified linesmodified:docs/guide.md+21 added-19 removed
89 unmodified lines90 ### Routing91 92 Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.93 For example we may want to render a user's account for the path _/user/12_, this94-can be done by defining the route below. The values associated to the named placeholders,95-are passed as the _third_ argument, which here we name _params_.94+can be done by defining the route below. The values associated to the named placeholders 95+are available as `req.params`.96 97- app.get('/user/:id', function(req, res, params){98- res.send('user ' + params.id);97+ app.get('/user/:id', function(req, res){98+ res.send('user ' + req.params.id);99 });100 101 A route is simple a string which is compiled to a _RegExp_ internally. For example102 when _/user/:id_ is compiled, a simplified version of the regexp may look similar to:103 104 \/user\/([^\/]+)\/?105 106 Regular expression literals may also be passed for complex uses. Since capture107-groups with literal _RegExp_'s are anonymous we can access them directly from the _params_ array.107+groups with literal _RegExp_'s are anonymous we can access them directly `req.params`.108 109- app.get(/^\/users?(?:\/(\d+)(?:\.\.(\d+))?)?/, function(req, res, params){110- res.send(params);109+ app.get(/^\/users?(?:\/(\d+)(?:\.\.(\d+))?)?/, function(req, res){110+ res.send(req.params);111 });112 113 Curl requests against the previously defined route:114 38 unmodified lines153 /products154 155 ### Passing Route Control156 157-We may pass control to the next _matching_ route, by calling the _fourth_ parameter,158-the _next()_ function. When a match cannot be made, control is passed back to Connect.157+We may pass control to the next _matching_ route, by calling the _third_ argument,158+the _next()_ function. When a match cannot be made, control is passed back to Connect,159+and middleware continue to be invoked.160 160- app.get('/users/:id?', function(req, res, params){161- if (params.id) {161+ app.get('/users/:id?', function(req, res){162+ var id = req.params.id;163+ if (id) {164 // do something165 } else {166 next();167 }168 });169 168- app.get('/users', function(req, res, params){170+ app.get('/users', function(req, res){171 // do something else172 });173 174 ### Middleware176 unmodified lines351 ### req.param(name)352 353 Return the value of param _name_ when present.354 353- - Checks route placeholders, ex: /user/:id354- - Checks query string params, ex: ?id=12355- - Checks urlencoded body params, ex: id=12355+ - Checks route placeholders (_req.params_), ex: /user/:id356+ - Checks query string params (_req.query_), ex: ?id=12357+ - Checks urlencoded body params (_req.body_), ex: id=12358 359 To utilize urlencoded request bodies, _req.body_360 should be an object. This can be done by using361 the _connect.bodyDecoder_ middleware.205 unmodified lines567 res.redirect('google');568 569 We may also map dynamic redirects:570 569- app.redirect('comments', function(req, res, params){570- return '/post/' + params.id + '/comments';571+ app.redirect('comments', function(req, res){572+ return '/post/' + req.params.id + '/comments';573 });574 575 So now we may do the following, and the redirect will dynamically adjust to576 the context of the request. If we called this route with _GET /post/12_ our30 unmodified lines607 608 ### app.dynamicHelpers(obj)609 610 Registers dynamic view helpers. Dynamic view helpers609-are simply functions which accept _req_, _res_, and _params_, and are611+are simply functions which accept _req_, _res_, and are612 evaluated against the _Server_ instance before a view is rendered. The _return value_ of this function613 becomes the local variable it is associated with.614 615 app.dynamicHelpers({614- session: function(req, res, params){616+ session: function(req, res){617 return req.session;618 }619 });620 41 unmodified linesmodified:docs/migrate.1+5 added-5 removed
163 unmodified lines164 .165 .IP "" 0166 .167 .P168-Route parameters are also passed as the third argument:168+Route parameters are available via \fBreq\.params\fR:169 .170 .IP "" 4171 .172 .nf173 174-app\.get(\'/user/:id\', function(req, res, params){175- params\.id;174+app\.get(\'/user/:id\', function(req, res){175+ req\.params\.id;176 });177 .178 .fi179 .14 unmodified lines194 .195 .IP "" 0196 .197 .P198-Now Express has access to Connect\'s \fInext()\fR function, which is passed as the fourth and final argument\. Calling \fInext()\fR will pass control to the next \fImatching route\fR, or continue down the stack of Connect middleware\.198+Now Express has access to Connect\'s \fInext()\fR function, which is passed as the third and final argument\. Calling \fInext()\fR will pass control to the next \fImatching route\fR, or continue down the stack of Connect middleware\.199 .200 .IP "" 4201 .202 .nf203 204-app\.get(\'/user/:id?\', function(req, res, params, next){204+app\.get(\'/user/:id?\', function(req, res, next){205 next();206 });207 208 app\.get(\'/user\', function(){139 unmodified linesmodified:docs/migrate.html+5 added-5 removed
296 unmodified lines297 req.param('id');298 });299 </code></pre>300 301-<p>Route parameters are also passed as the third argument:</p>301+<p>Route parameters are available via <code>req.params</code>:</p>302 303-<pre><code>app.get('/user/:id', function(req, res, params){304- params.id;303+<pre><code>app.get('/user/:id', function(req, res){304+ req.params.id;305 });306 </code></pre>307 308 <h3 id="Passing-Route-Control">Passing Route Control</h3>7 unmodified lines316 });317 </code></pre>318 319 <p>Now Express has access to Connect's <em>next()</em> function,320-which is passed as the fourth and final argument. Calling <em>next()</em> will320+which is passed as the third and final argument. Calling <em>next()</em> will321 pass control to the next <em>matching route</em>, or continue down the stack322 of Connect middleware.</p>323 324-<pre><code>app.get('/user/:id?', function(req, res, params, next){324+<pre><code>app.get('/user/:id?', function(req, res, next){325 next();326 });327 328 app.get('/user', function(){83 unmodified linesmodified:docs/migrate.md+5 added-5 removed
95 unmodified lines969798991001001011021031021031041051061075 unmodified lines11311411511611711711811912012112112212312412567 unmodified lines95 unmodified lines app.get('/user/:id', function(req, res){ req.param('id'); });
Route parameters are also passed as the third argument:Route parameters are available via `req.params`:
app.get('/user/:id', function(req, res, params){ params.id; app.get('/user/:id', function(req, res){ req.params.id; });
### Passing Route Control
5 unmodified lines this.pass('/foobar'); });
Now Express has access to Connect's _next()_ function,which is passed as the fourth and final argument. Calling _next()_ willwhich is passed as the third and final argument. Calling _next()_ willpass control to the next _matching route_, or continue down the stackof Connect middleware.
app.get('/user/:id?', function(req, res, params, next){ app.get('/user/:id?', function(req, res, next){ next(); });
app.get('/user', function(){67 unmodified lines