#json-rpc-server

prople-jsonrpc-axum

A library provides a core of abstraction to working with JSON-RPC

8 releases

0.2.1 Oct 4, 2024
0.2.0 Sep 7, 2024
0.1.5 Aug 28, 2024
0.1.0 Jun 24, 2024

#25 in #json-rpc-server

Download history 414/week @ 2024-08-23 54/week @ 2024-08-30 173/week @ 2024-09-06 40/week @ 2024-09-13 14/week @ 2024-09-20 9/week @ 2024-09-27 136/week @ 2024-10-04 11/week @ 2024-10-11

148 downloads per month
Used in prople-vesseld

GPL-3.0-only

51KB
788 lines

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"}

Dependencies

~16–29MB
~422K SLoC