17 unstable releases (6 breaking)

0.7.1 Jul 2, 2024
0.7.0 Mar 25, 2024
0.6.1 Jan 6, 2024
0.5.1 Apr 27, 2023
0.2.1 Jul 28, 2022

#403 in Network programming

Download history 486/week @ 2024-07-23 470/week @ 2024-07-30 458/week @ 2024-08-06 411/week @ 2024-08-13 374/week @ 2024-08-20 245/week @ 2024-08-27 393/week @ 2024-09-03 406/week @ 2024-09-10 368/week @ 2024-09-17 356/week @ 2024-09-24 389/week @ 2024-10-01 313/week @ 2024-10-08 458/week @ 2024-10-15 454/week @ 2024-10-22 316/week @ 2024-10-29 253/week @ 2024-11-05

1,527 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–13MB
~152K SLoC