app.all()

Matches all HTTP methods for a given path.

Since Express 4 Spec ↗

Syntax

app.all(path, ...handlers)

Parameters

NameTypeRequiredDescription
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.

See also