#json-rpc #json-rpc-server #axum #abstraction #api #prople #tokio

prople-jsonrpc-axum

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

7 releases

0.2.0 Sep 7, 2024
0.1.5 Aug 28, 2024
0.1.0 Jun 24, 2024

#1546 in Network programming

Download history 135/week @ 2024-06-22 2/week @ 2024-06-29 434/week @ 2024-08-24 34/week @ 2024-08-31 184/week @ 2024-09-07

652 downloads per month
Used in prople-vesseld

GPL-3.0-only

52KB
812 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–28MB
~438K SLoC