basic/basic.rs
1use jsonrpc_core::*;
2
3fn main() {
4 let mut io = IoHandler::new();
5
6 io.add_sync_method("say_hello", |_: Params| Ok(Value::String("Hello World!".to_owned())));
7
8 let request = r#"{"jsonrpc": "2.0", "method": "say_hello", "params": [42, 23], "id": 1}"#;
9 let response = r#"{"jsonrpc":"2.0","result":"hello","id":1}"#;
10
11 assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
12}