1
0
mirror of https://github.com/actix/examples synced 2024-12-18 00:13:57 +01:00
examples/jsonrpc
2019-09-05 00:04:57 +09:00
..
src Fix clippy warnings (#168) 2019-09-05 00:04:57 +09:00
tests Add jsonrpc example 2019-04-15 10:05:22 +08:00
Cargo.toml update actix-web to 1.0.0 2019-06-06 16:47:40 +06:00
README.md Update README.md 2019-04-15 14:16:38 +08:00

A simple demo for building a JSONRPC over HTTP server in actix-web.

Server

$ 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.