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/docs/basics/routes.md
+70-1Lines changed: 70 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,8 +165,77 @@ curl --request POST \
165
165
The body is "Hello!".
166
166
```
167
167
168
-
:::tip
168
+
#### JSON
169
+
169
170
When the `Content-Type` is `application/json`, you can use `context.request.json()` to read the contents of the request body as a `Map<String, dynamic>`.
We can make a request to the above handler with some data and we should see:
187
+
188
+
```
189
+
curl --request POST \
190
+
--url http://localhost:8080/example \
191
+
--header 'Content-Type: application/json' \
192
+
--data '{
193
+
"hello": "world"
194
+
}'
195
+
196
+
{
197
+
"request_body": {
198
+
"hello": "world"
199
+
}
200
+
}
201
+
```
202
+
203
+
#### Form Data
204
+
205
+
When the `Content-Type` is `application/x-www-form-urlencoded`, you can use `context.request.formData()` to read the contents of the request body as a `Map<String, String>`.
0 commit comments