Skip to content
Myr

Control passing 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 da84c0b · Browse files · 3 files+81 added−0 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+81 added−0 removed

  • other:+81 added−0 removed

3 files+81 added−0 removed

modified:docs/migrate.1+34 added
103 unmodified lines
104.105.fi106.107.IP "" 0108.109.SS "Passing Route Control"110Old express had a weak notion of route passing, which did not support async, and was never properly implemented for practical use:111.112.IP "" 4113.114.nf115116get(\'/\', function(){117 this\.pass(\'/foobar\');118});119.120.fi121.122.IP "" 0123.124.P125Now Express has access to Connect\'s \fBnext()\fR function, which is passed as the fourth and final argument\. Calling \fBnext()\fR will pass control to the next \fImatching route\fR, or continue down the stack of Connect middleware\.126.127.IP "" 4128.129.nf130131app\.get(\'/user/:id?\', function(req, res, params, next){132 next();133});134135app\.get(\'/user\', function(){136 // \.\.\. respond137});138.139.fi140.141.IP "" 0142
modified:docs/migrate.html+25 added
218 unmodified lines
219 params.id;220});221</code></pre>222223<h3 id="Passing-Route-Control">Passing Route Control</h3>224225<p>Old express had a weak notion of route passing,226which did not support async, and was never properly227implemented for practical use:</p>228229<pre><code>get('/', function(){230 this.pass('/foobar');231});232</code></pre>233234<p>Now Express has access to Connect's <code>next()</code> function,235which is passed as the fourth and final argument. Calling <code>next()</code> will236pass control to the next <em>matching route</em>, or continue down the stack237of Connect middleware.</p>238239<pre><code>app.get('/user/:id?', function(req, res, params, next){240 next();241});242243app.get('/user', function(){244 // ... respond245});246</code></pre>247248</div>249 </div>250 </div>251 </body>
1 unmodified line
modified:docs/migrate.md+22 added