app.all()
Matches all HTTP methods for a given path.
Syntax
app.all(path, ...handlers) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
path | string | RegExp | Yes | The route path. |
handlers | ...function | Yes | The handler chain run for any HTTP verb. |
Returns
Application — The app instance, for chaining.
Examples
app.all('/api/*splat', (req, res, next) => {
console.log(`${req.method} ${req.path}`);
next();
});
Output
GET /api/users
app.all('/secret', requireAuth, (req, res) => {
res.send(`handled ${req.method}`);
});
Output
$ curl -X POST localhost:3000/secret
handled POST
Notes
Useful for cross-cutting logic (auth, logging) on a path regardless
of method. In Express 5 wildcard segments must be named (e.g.
`*splat`); bare `*` is no longer valid path syntax.