Skip to content

Commit 5cbf8b4

Browse files
committed
docs: add router callable API
1 parent ddcc534 commit 5cbf8b4

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

src/content/api/4x/api/router/index.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,31 @@ router.get('/events', (req: Request, res: Response) => {
121121
app.use('/calendar', router);
122122
```
123123

124+
### router(req, res, [next])
125+
126+
<Signature>
127+
<Fragment slot="attributes">
128+
<Param name="req" type="Request">
129+
The request object.
130+
</Param>
131+
<Param name="res" type="Response">
132+
The response object.
133+
</Param>
134+
<Param name="next" type="Function" optional>
135+
The callback to pass control to the next matching middleware.
136+
</Param>
137+
</Fragment>
138+
</Signature>
139+
140+
Dispatches `req` and `res` through the router's middleware and route stack.
141+
Express uses this callable form when a router is mounted with `app.use()` or
142+
`router.use()`.
143+
144+
If no middleware ends the response, or if a middleware passes control by calling
145+
`next()`, the optional `next` callback receives control. If a middleware calls
146+
`next(err)`, Express skips the remaining non-error handlers and calls `next` with
147+
the error.
148+
124149
### router.all()
125150

126151
<Signature returns="Router">

src/content/api/5x/api/router/index.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,31 @@ router.get('/events', (req: Request, res: Response) => {
121121
app.use('/calendar', router);
122122
```
123123

124+
### router(req, res, [next])
125+
126+
<Signature>
127+
<Fragment slot="attributes">
128+
<Param name="req" type="Request">
129+
The request object.
130+
</Param>
131+
<Param name="res" type="Response">
132+
The response object.
133+
</Param>
134+
<Param name="next" type="Function" optional>
135+
The callback to pass control to the next matching middleware.
136+
</Param>
137+
</Fragment>
138+
</Signature>
139+
140+
Dispatches `req` and `res` through the router's middleware and route stack.
141+
Express uses this callable form when a router is mounted with `app.use()` or
142+
`router.use()`.
143+
144+
If no middleware ends the response, or if a middleware passes control by calling
145+
`next()`, the optional `next` callback receives control. If a middleware calls
146+
`next(err)`, Express skips the remaining non-error handlers and calls `next` with
147+
the error.
148+
124149
### router.all()
125150

126151
<Signature returns="Router">

0 commit comments

Comments
 (0)