Skip to content

Commit c0c9f9f

Browse files
authored
Update README.md to match example in main repo (and not be broken)
Resolves paritytech#596 This grabs the example server implementation from [the root README](https://github.com/paritytech/jsonrpc#basic-usage-with-http-transport), as the given example ([rendered in docs.rs](https://paritytech.github.io/jsonrpc/jsonrpc_http_server/index.html)) currently fails with the following: ``` error[E0277]: `Result<jsonrpc_http_server::jsonrpc_core::Value, _>` is not a future --> src/main.rs:6:5 | 6 | io.add_method("say_hello", |_| { | ^^^^^^^^^^ `Result<jsonrpc_http_server::jsonrpc_core::Value, _>` is not a future | = help: the trait `std::future::Future` is not implemented for `Result<jsonrpc_http_server::jsonrpc_core::Value, _>` = note: required because of the requirements on the impl of `RpcMethodSimple` for `[closure@src/main.rs:6:29: 8:3]` ```
1 parent dc6b8ed commit c0c9f9f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

http/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ Rust http server using JSON-RPC 2.0.
99

1010
```
1111
[dependencies]
12-
jsonrpc-http-server = "15.0"
12+
jsonrpc-http-server = "18.0"
1313
```
1414

1515
`main.rs`
1616

1717
```rust
18-
use jsonrpc_http_server::*;
19-
use jsonrpc_http_server::jsonrpc_core::*;
18+
use jsonrpc_http_server::jsonrpc_core::{IoHandler, Value, Params};
19+
use jsonrpc_http_server::ServerBuilder;
2020

2121
fn main() {
2222
let mut io = IoHandler::default();
23-
io.add_method("say_hello", |_| {
24-
Ok(Value::String("hello".into()))
23+
io.add_method("say_hello", |_params: Params| async {
24+
Ok(Value::String("hello".to_owned()))
2525
});
2626

2727
let server = ServerBuilder::new(io)
28-
.cors(DomainsValidation::AllowOnly(vec![AccessControlAllowOrigin::Null]))
28+
.threads(3)
2929
.start_http(&"127.0.0.1:3030".parse().unwrap())
30-
.expect("Unable to start RPC server");
30+
.unwrap();
3131

3232
server.wait();
3333
}

0 commit comments

Comments
 (0)