2018-04-13 09:18:42 +08:00
|
|
|
# json
|
|
|
|
|
2022-02-06 08:25:38 +00:00
|
|
|
Json's `Getting Started` guide using json (serde-json or json-rust) for Actix Web
|
2018-04-13 09:18:42 +08:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### server
|
|
|
|
|
2022-02-18 03:36:04 +00:00
|
|
|
```sh
|
2021-10-06 17:28:53 -04:00
|
|
|
cd json/json
|
2018-04-13 09:18:42 +08:00
|
|
|
cargo run
|
|
|
|
# Started http server: 127.0.0.1:8080
|
|
|
|
```
|
|
|
|
|
|
|
|
### web client
|
|
|
|
|
|
|
|
With [Postman](https://www.getpostman.com/) or [Rested](moz-extension://60daeb1c-5b1b-4afd-9842-0579ed34dfcb/dist/index.html)
|
|
|
|
|
|
|
|
- POST / (embed serde-json):
|
|
|
|
|
2022-03-06 00:43:10 +00:00
|
|
|
- method : `POST`
|
|
|
|
- url : `http://127.0.0.1:8080/`
|
|
|
|
- header : `Content-Type` = `application/json`
|
|
|
|
- body (raw) : `{"name": "Test user", "number": 100}`
|
2018-04-13 09:18:42 +08:00
|
|
|
|
|
|
|
- POST /manual (manual serde-json):
|
|
|
|
|
2022-03-06 00:43:10 +00:00
|
|
|
- method : `POST`
|
|
|
|
- url : `http://127.0.0.1:8080/manual`
|
|
|
|
- header : `Content-Type` = `application/json`
|
|
|
|
- body (raw) : `{"name": "Test user", "number": 100}`
|
2018-04-13 09:18:42 +08:00
|
|
|
|
|
|
|
- POST /mjsonrust (manual json-rust):
|
|
|
|
|
2022-03-06 00:43:10 +00:00
|
|
|
- method : `POST`
|
|
|
|
- url : `http://127.0.0.1:8080/mjsonrust`
|
|
|
|
- header : `Content-Type` = `application/json`
|
|
|
|
- body (raw) : `{"name": "Test user", "number": 100}` (you can also test `{notjson}`)
|
2018-04-13 09:18:42 +08:00
|
|
|
|
|
|
|
### python client
|
|
|
|
|
2022-03-06 00:43:10 +00:00
|
|
|
- `pip install aiohttp`
|
|
|
|
- `python client.py`
|
2018-04-13 09:18:42 +08:00
|
|
|
|
|
|
|
if ubuntu :
|
|
|
|
|
2022-03-06 00:43:10 +00:00
|
|
|
- `pip3 install aiohttp`
|
|
|
|
- `python3 client.py`
|