prople-jsonrpc-axum

Crates.ioprople-jsonrpc-axum
lib.rsprople-jsonrpc-axum
version0.2.1
sourcesrc
created_at2024-06-24 09:18:09.254309
updated_at2024-10-04 11:57:32.996973
descriptionA library provides a core of abstraction to working with JSON-RPC
homepage
repositoryhttps://github.com/prople/jsonrpc/core
max_upload_size
id1282047
size41,589
(rstlix0x0)

documentation

README

prople/jsonrpc/axum

An implementation of JSON-RPC server using Tokio Axum.

WARNING!

There is a breaking changes from 0.1.x to latest version: 0.2.0

Please always use the latest version which provides more nicer API

Usages

use rst_common::with_tokio::tokio;
use prople_jsonrpc_axum::rpc::{RpcConfig, RpcError, Rpc};

#[tokio::main]
async fn main() -> Result<(), RpcError> {
    // you need to configure your `RpcProcessor`
    // assumed you have already set the object
    let state = RpcState::new(processor);
    let config = RpcConfig::new(String::from("host"), String::from("port"));

    // assumed you've already set your Axum's endpoint Router
    // the `app` variable defined here should be an instance of axum::Router
    let rpc = Rpc::new(config, state, app);
    let _ = rpc.serve()?;
}

Installation

[dependencies]
prople-jsonrpc-axum = {version = "0.2.0"}
Commit count: 0

cargo fmt