Skip to content

Commit 7b5e678

Browse files
authored
docs(routes): include nested dynamic routes (#478)
1 parent 2e55588 commit 7b5e678

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/docs/basics/routes.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ Future<Response> onRequest(RequestContext context) async {
350350

351351
## Dynamic Routes 🌓
352352

353-
Dart Frog supports dynamic routes. For example, if you create a file called `routes/posts/[id].dart`, then it will be accessible at `/posts/1`, `/posts/2`, etc.
353+
Dart Frog supports dynamic routes. For example, if you create a file called `routes/posts/[id].dart`, then it will be accessible at `/posts/1`, `/posts/2`, and so on.
354354

355355
Routing parameters are forwarded to the `onRequest` method as seen below.
356356

@@ -362,6 +362,16 @@ Response onRequest(RequestContext context, String id) {
362362
}
363363
```
364364

365+
Dart Frog also supports nested dynamic routes. For example, if you create a file called, `routes/users/[userId]/posts/[postId].dart`, then it will be accessible at `/users/alice/posts/1`, `/users/sam/posts/42`, and so on.
366+
367+
Just as with all dynamic routes, routing parameters are forwarded to the `onRequest` method:
368+
369+
```dart
370+
Response onRequest(RequestContext context, String userId, String postId) {
371+
return Response(body: 'user id: $userId, post id: $postId');
372+
}
373+
```
374+
365375
## Route Conflicts 💥
366376

367377
When defining routes, it's possible to encounter route conflicts.

0 commit comments

Comments
 (0)