Skip to content

Commit

Permalink
docs(routes): include nested dynamic routes (felangel#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Jan 19, 2023
1 parent 2e55588 commit 7b5e678
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/docs/basics/routes.md
Expand Up @@ -350,7 +350,7 @@ Future<Response> onRequest(RequestContext context) async {

## Dynamic Routes 🌓

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

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

Expand All @@ -362,6 +362,16 @@ Response onRequest(RequestContext context, String id) {
}
```

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.

Just as with all dynamic routes, routing parameters are forwarded to the `onRequest` method:

```dart
Response onRequest(RequestContext context, String userId, String postId) {
return Response(body: 'user id: $userId, post id: $postId');
}
```

## Route Conflicts 💥

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

0 comments on commit 7b5e678

Please sign in to comment.