框架仓库
https://github.com/paritytech/jsonrpc#readme
使用
1.依赖
[dependencies]
jsonrpc-core = "18.0.0"
jsonrpc-core-client = "18.0.0"
jsonrpc-http-server = "18.0.0"
jsonrpc-ipc-server = "18.0.0"
jsonrpc-tcp-server= "18.0.0"
jsonrpc-ws-server = "18.0.0"
jsonrpc-stdio-server = "18.0.0"
jsonrpc-derive = "18.0.0"
jsonrpc-server-utils = "18.0.0"
jsonrpc-pubsub = "18.0.0"
2.hello wold
use jsonrpc_http_server::jsonrpc_core::{IoHandler, Params, Value};
use jsonrpc_http_server::ServerBuilder;
pub fn start_rpc_server() {
let mut io = IoHandler::default();
// 注册了一个say_hello方法,忽略参数,直接返回hello
io.add_method("say_hello", |_params: Params| async {
Ok(Value::String("hello".to_owned()))
});
let server = ServerBuilder::new(io)
.t

最低0.47元/天 解锁文章
456

被折叠的 条评论
为什么被折叠?



