16 unstable releases (6 breaking)

0.7.0 Mar 25, 2024
0.5.2 Jan 6, 2024
0.5.1 Apr 27, 2023
0.4.0 Feb 15, 2023
0.2.1 Jul 28, 2022

#883 in Network programming

Download history 642/week @ 2023-12-25 846/week @ 2024-01-01 892/week @ 2024-01-08 794/week @ 2024-01-15 810/week @ 2024-01-22 706/week @ 2024-01-29 849/week @ 2024-02-05 340/week @ 2024-02-12 219/week @ 2024-02-19 269/week @ 2024-02-26 345/week @ 2024-03-04 412/week @ 2024-03-11 375/week @ 2024-03-18 393/week @ 2024-03-25 498/week @ 2024-04-01 167/week @ 2024-04-08

1,443 downloads per month

MIT license

25KB
604 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

~5.5–8.5MB
~154K SLoC