Uses old Rust 2015
0.4.0 |
|
---|---|
0.3.0 |
|
0.2.0 |
|
0.1.2 |
|
0.1.1 |
|
#12 in #server-builder
Used in 2 crates
115KB
3K
SLoC
jsonrpc-tcp-server
TCP server for JSON-RPC 2.0.
Example
Cargo.toml
[dependencies]
jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc" }
main.rs
extern crate jsonrpc_tcp_server;
use jsonrpc_tcp_server::*;
use jsonrpc_tcp_server::jsonrpc_core::*;
fn main() {
let mut io = IoHandler::default();
io.add_method("say_hello", |_params| {
Ok(Value::String("hello".to_owned()))
});
let server = ServerBuilder::new(io)
.start(&"0.0.0.0:3030".parse().unwrap())
.expect("Server must start with no issues");
server.wait().unwrap()
}
lib.rs
:
jsonrpc server over tcp/ip
extern crate solana_jsonrpc_core as jsonrpc_core;
extern crate solana_jsonrpc_tcp_server as jsonrpc_tcp_server;
use jsonrpc_core::*;
use jsonrpc_tcp_server::ServerBuilder;
fn main() {
let mut io = IoHandler::default();
io.add_method("say_hello", |_params| {
Ok(Value::String("hello".to_string()))
});
let server = ServerBuilder::new(io)
.start(&"0.0.0.0:0".parse().unwrap())
.expect("Server must start with no issues.");
server.wait();
}
Dependencies
~11MB
~184K SLoC