mirror of
https://gitlab.silvrtree.co.uk/martind2000/frontexpress.git
synced 2025-01-12 05:25:09 +00:00
40 lines
767 B
Markdown
40 lines
767 B
Markdown
|
# Router
|
||
|
|
||
|
## Router.use(middleware)
|
||
|
|
||
|
Use the given middleware function or object on this router.
|
||
|
|
||
|
```js
|
||
|
// middleware function
|
||
|
router.use((req, res, next) => {console.log('Hello')});
|
||
|
|
||
|
// middleware object
|
||
|
router.use(new Middleware());
|
||
|
```
|
||
|
|
||
|
**Parameters**
|
||
|
|
||
|
**middleware**: `Middleware | function`, Middleware object or function
|
||
|
|
||
|
**Returns**: `Router`, for chaining
|
||
|
|
||
|
|
||
|
## Router.all(middleware)
|
||
|
|
||
|
Use the given middleware function or object on this router for
|
||
|
all HTTP methods.
|
||
|
|
||
|
```js
|
||
|
// middleware function
|
||
|
router.all((req, res, next) => {console.log('Hello')});
|
||
|
|
||
|
// middleware object
|
||
|
router.all(new Middleware());
|
||
|
```
|
||
|
|
||
|
**Parameters**
|
||
|
|
||
|
**middleware**: `Middleware | function`, Middleware object or function
|
||
|
|
||
|
**Returns**: `Router`, for chaining
|