18 releases

0.8.0 Jan 9, 2025
0.7.1 Jul 2, 2024
0.7.0 Mar 25, 2024
0.5.1 Apr 27, 2023
0.2.1 Jul 28, 2022

#1265 in Network programming

Download history 304/week @ 2024-12-04 328/week @ 2024-12-11 198/week @ 2024-12-18 127/week @ 2024-12-25 242/week @ 2025-01-01 426/week @ 2025-01-08 571/week @ 2025-01-15 527/week @ 2025-01-22 315/week @ 2025-01-29 301/week @ 2025-02-05 439/week @ 2025-02-12 301/week @ 2025-02-19 433/week @ 2025-02-26 265/week @ 2025-03-05 205/week @ 2025-03-12 385/week @ 2025-03-19

1,373 downloads per month

MIT license

25KB
603 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
~148K SLoC