1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00
examples/json/jsonrpc
XT c15a176b1c
fix: added skip_serialization for JSON fields (#632)
Co-authored-by: Rob Ede <robjtede@icloud.com>
2023-10-29 23:28:44 +00:00
..
src fix: added skip_serialization for JSON fields (#632) 2023-10-29 23:28:44 +00:00
tests Restructure folders (#411) 2021-02-26 00:57:58 +00: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

A simple demo for building a JSONRPC over HTTP server using Actix Web.

Server

cd json/jsonrpc
cargo run
# Starting server on 127.0.0.1:8080

Client

curl

$ 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

$ python tests\test_client.py
# {'jsonrpc': '2.0', 'result': 'pong', 'error': None, 'id': 1}

Methods

  • ping: Pong immeditely
  • wait: Wait n seconds, and then pong
  • get: Get global count
  • inc: Increment global count

See tests\test_client.py to get more information.