1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00
examples/json/json-validation/README.md

22 lines
895 B
Markdown
Raw Permalink Normal View History

2022-02-06 09:13:24 +01:00
This is a contrived example intended to illustrate a few important Actix Web features.
2018-04-27 21:31:34 +02:00
2022-03-06 01:43:10 +01:00
_Imagine_ that you have a process that involves 3 steps. The steps here are dumb in that they do nothing other than call an HTTP endpoint that returns the json that was posted to it. The intent here is to illustrate how to chain these steps together as futures and return a final result in a response.
2018-04-27 21:30:29 +02:00
Actix Web features illustrated here include:
2018-04-27 21:31:34 +02:00
2018-04-27 21:30:29 +02:00
1. handling json input param
2. validating user-submitted parameters using the 'validator' crate
2022-02-06 09:13:24 +01:00
2. `awc` client features:
2018-04-27 21:30:29 +02:00
- POSTing json body
3. chaining futures into a single response used by an asynch endpoint
### server
2022-02-18 04:36:04 +01:00
```sh
cd basics/json-validation
cargo run
# Started http server: 127.0.0.1:8080
```
2022-03-06 01:43:10 +01:00
Example query from the command line using httpie: `echo '{"id":"1", "name": "JohnDoe"}' | http 127.0.0.1:8080/something`