mount method

void mount(
  1. String path,
  2. Handler handler
)

Hands everything under path to handler.

The counterpart to shelf_router.mount and axum's nest_service. The handler sees paths relative to path, so a shelf_static handler, or any other framework's handler, works unchanged:

app.mount('/assets', createStaticHandler('public'));

mount('/') claims every path, which is how a single-page build is served. Declare the routes that must win above it: the first declaration that matches is the one that runs, and that counts route, mount, and nest alike, in the order they were written.

Implementation

void mount(String path, Handler handler) {
  _requireOpen();
  final route = Route.mount(normalizePrefix(path), handler);
  internals.routes.add(route);
  internals.declarations.add(route);
}