1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00
examples/json/json-validation
2023-01-02 20:35:11 +00:00
..
src update some easy deps 2022-07-09 22:54:51 +01:00
Cargo.toml move serde deps to workspace 2023-01-02 20:35:11 +00:00
README.md format markdown 2022-03-06 00:43:10 +00:00

This is a contrived example intended to illustrate a few important Actix Web features.

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.

Actix Web features illustrated here include:

1. handling json input param
2. validating user-submitted parameters using the 'validator' crate
2. `awc` client features:
      - POSTing json body
3. chaining futures into a single response used by an asynch endpoint

server

cd basics/json-validation
cargo run
# Started http server: 127.0.0.1:8080

Example query from the command line using httpie: echo '{"id":"1", "name": "JohnDoe"}' | http 127.0.0.1:8080/something