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

35 lines
726 B
Markdown
Raw Permalink Normal View History

2022-02-06 09:13:24 +01:00
A simple demo for building a `JSONRPC over HTTP` server using [Actix Web](https://github.com/actix/actix-web).
2019-04-15 04:05:22 +02:00
# Server
```sh
cd json/jsonrpc
cargo run
2019-04-15 04:05:22 +02:00
# Starting server on 127.0.0.1:8080
```
# Client
**curl**
```sh
$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "ping", "params": [], "id": 1}' http://127.0.0.1:8080
# {"jsonrpc":"2.0","result":"pong","error":null,"id":1}
```
**python**
```sh
$ python tests\test_client.py
# {'jsonrpc': '2.0', 'result': 'pong', 'error': None, 'id': 1}
```
# Methods
- `ping`: Pong immeditely
2019-04-15 08:16:38 +02:00
- `wait`: Wait `n` seconds, and then pong
2019-04-15 04:05:22 +02:00
- `get`: Get global count
- `inc`: Increment global count
See `tests\test_client.py` to get more information.