You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/event_handler/api_gateway.md
+20-63Lines changed: 20 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,8 +196,8 @@ You can use `/todos/<todo_id>` to configure dynamic URL paths, where `<todo_id>`
196
196
197
197
Each dynamic route you set must be part of your function signature. This allows us to call your function using keyword arguments when matching your dynamic route.
198
198
199
-
???+ note
200
-
For brevity, we will only include the necessary keys for each sample request for the example to work.
199
+
???+ tip
200
+
You can also nest dynamic paths, for example `/todos/<todo_id>/<todo_status>`.
201
201
202
202
=== "dynamic_routes.py"
203
203
@@ -211,37 +211,31 @@ Each dynamic route you set must be part of your function signature. This allows
You can also nest dynamic paths, for example `/todos/<todo_id>/<todo_status>`.
216
-
217
-
#### Dynamic Path Parameters
214
+
#### Dynamic path mechanism
218
215
219
216
Dynamic path parameters are defined using angle brackets `<parameter_name>` syntax. These parameters are automatically converted to regex patterns for efficient route matching and performance gains.
220
217
221
218
**Syntax**: `/path/<parameter_name>`
222
219
223
220
***Parameter names** must contain only word characters (letters, numbers, underscore)
224
-
***Captured values** can contain letters, numbers, underscores, and these special characters: `-._~()'!*:@,;=+&$%<> \[]{}|^`
221
+
***Captured values** can contain letters, numbers, underscores, and these special characters: `-._~()'!*:@,;=+&$%<> \[]{}|^`. Reserved characters must be percent-encoded in URLs to prevent errors.
@@ -250,14 +244,13 @@ Dynamic path parameters are defined using angle brackets `<parameter_name>` synt
250
244
251
245
#### Catch-all routes
252
246
253
-
???+ note
254
-
We recommend having explicit routes whenever possible; use catch-all routes sparingly.
255
-
256
247
For scenarios where you need to handle arbitrary or deeply nested paths, you can use regex patterns directly in your route definitions. These are particularly useful for proxy routes or when dealing with file paths.
257
248
249
+
**We recommend** having explicit routes whenever possible; use catch-all routes sparingly.
250
+
258
251
##### Using Regex Patterns
259
252
260
-
You can use standard [Python regex patterns](https://docs.python.org/3/library/re.html#regular-expression-syntax){target="_blank" rel="nofollow"} in your route definitions:
253
+
You can use standard [Python regex patterns](https://docs.python.org/3/library/re.html#regular-expression-syntax){target="_blank" rel="nofollow"} in your route definitions, for example:
261
254
262
255
| Pattern | Description | Examples |
263
256
|---------|-------------|----------|
@@ -266,53 +259,17 @@ You can use standard [Python regex patterns](https://docs.python.org/3/library/r
266
259
|`[^/]+`| Matches one or more non-slash characters |`/api/[^/]+` matches `/api/v1` but not `/api/v1/users`|
267
260
|`\w+`| Matches one or more word characters |`/users/\w+` matches `/users/john123`|
268
261
269
-
**Common Regex Route Examples:**
270
-
271
-
```python
272
-
# File path proxy - captures everything after /files/
0 commit comments