13 unstable releases (4 breaking)

0.5.1 Apr 27, 2023
0.5.0 Apr 27, 2023
0.4.0 Feb 15, 2023
0.3.2 Nov 25, 2022
0.1.4 Apr 29, 2022

#793 in Network programming

Download history 290/week @ 2023-02-01 274/week @ 2023-02-08 426/week @ 2023-02-15 563/week @ 2023-02-22 496/week @ 2023-03-01 290/week @ 2023-03-08 727/week @ 2023-03-15 644/week @ 2023-03-22 604/week @ 2023-03-29 759/week @ 2023-04-05 851/week @ 2023-04-12 866/week @ 2023-04-19 1019/week @ 2023-04-26 954/week @ 2023-05-03 1029/week @ 2023-05-10 815/week @ 2023-05-17

3,973 downloads per month

MIT license

23KB
573 lines

Json RPC extractor for axum

JsonRpcExtractor parses JSON-RPC requests and validates it's correctness.

use axum_jrpc::{JrpcResult, JsonRpcExtractor, JsonRpcResponse};

fn router(req: JsonRpcExtractor) -> JrpcResult {
    let req_id = req.get_answer_id()?;
    let method = req.method();
    let response =
        match method {
            "add" => {
                let params: [i32; 2] = req.parse_params()?;
                JsonRpcResponse::success(req_id, params[0] + params[1]);
            }
            m => req.method_not_found(m)
        };

    Ok(response)
}

Crates.io Documentation

Dependencies

~6–12MB
~207K SLoC