1 stable release
Uses old Rust 2015
8.0.0 | May 14, 2019 |
---|
#1171 in HTTP server
135KB
3.5K
SLoC
rs-jsonrpc-http-server
Rust http server using JSON-RPC 2.0.
Example
Cargo.toml
[dependencies]
rs-jsonrpc-core = { git = "https://github.com/susytech/s-jsonrpc" }
rs-jsonrpc-http-server = { git = "https://github.com/susytech/s-jsonrpc" }
main.rs
extern crate rs_jsonrpc_core;
extern crate rs_jsonrpc_http_server;
use rs_jsonrpc_core::*;
use rs_jsonrpc_http_server::*;
fn main() {
let mut io = IoHandler::default();
io.add_method("say_hello", |_| {
Ok(Value::String("hello".into()))
});
let server = ServerBuilder::new(io)
.cors(DomainsValidation::AllowOnly(vec![AccessControlAllowOrigin::Null]))
.start_http(&"127.0.0.1:3030".parse().unwrap())
.expect("Unable to start RPC server");
server.wait().unwrap();
}
lib.rs
:
jsonrpc http server.
extern crate rs_jsonrpc_core;
extern crate rs_jsonrpc_http_server;
use rs_jsonrpc_core::*;
use rs_jsonrpc_http_server::*;
fn main() {
let mut io = IoHandler::new();
io.add_method("say_hello", |_: Params| {
Ok(Value::String("hello".to_string()))
});
let _server = ServerBuilder::new(io).start_http(&"127.0.0.1:3030".parse().unwrap());
}
Dependencies
~14MB
~255K SLoC