Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/06-concepts/18-webserver/01-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Routes are added with a path pattern:
pod.webServer.addRoute(UserRoute(), '/api/users');

// Path with wildcard
pod.webServer.addRoute(StaticRoute.directory(Directory('web')), '/static/**');
pod.webServer.addRoute(StaticRoute.directory(Directory('web')), '/static/');
```

Routes are matched in the order they were added.
Expand Down Expand Up @@ -115,7 +115,7 @@ For serving CSS, JavaScript, images, or other static assets:
```dart
pod.webServer.addRoute(
StaticRoute.directory(Directory('web/static')),
'/static/**',
'/static/',
);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/06-concepts/18-webserver/02-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pod.webServer.addRoute(
Directory('web/admin'),
host: 'admin.example.com',
),
'/static/**',
'/static/',
);

// SPA for a specific host
Expand Down
11 changes: 5 additions & 6 deletions docs/06-concepts/18-webserver/05-static-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final staticDir = Directory('web/static');

pod.webServer.addRoute(
StaticRoute.directory(staticDir),
'/static/**',
'/static/',
);
```

Expand All @@ -22,9 +22,8 @@ For example, `web/static/logo.png` becomes accessible at `/static/logo.png`.

:::info

The `/**` tail-match wildcard is required for serving directories. It matches all
paths under the prefix, allowing `StaticRoute` to map URLs to file system paths.
See [Routing](routing#wildcards) for more on wildcards.
`StaticRoute.directory()` automatically handles tail matching, so you don't need
to add `**` to the path. The route will serve all files under the given prefix.

:::

Expand All @@ -39,7 +38,7 @@ pod.webServer.addRoute(
staticDir,
cacheControlFactory: StaticRoute.publicImmutable(maxAge: const Duration(minutes: 5)),
),
'/static/**',
'/static/',
);
```

Expand Down Expand Up @@ -67,7 +66,7 @@ pod.webServer.addRoute(
cacheBustingConfig: cacheBustingConfig,
cacheControlFactory: StaticRoute.publicImmutable(maxAge: const Duration(minutes: 5)),
),
'/static/**',
'/static/',
);
```

Expand Down
6 changes: 3 additions & 3 deletions docs/08-upgrading/01-upgrade-to-three.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pod.webServer.addRoute(
```dart
pod.webServer.addRoute(
StaticRoute.directory(Directory('web/static')),
'/static/**',
'/static/',
);
```

Expand All @@ -194,7 +194,7 @@ pod.webServer.addRoute(
Directory('web/static'),
cacheControlFactory: StaticRoute.publicImmutable(maxAge: 3600),
),
'/static/**',
'/static/',
);
```

Expand All @@ -217,7 +217,7 @@ pod.webServer.addRoute(
immutable: true,
),
),
'/static/**',
'/static/',
);
```

Expand Down
Loading