18 releases

new 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

#1353 in Network programming

Download history 368/week @ 2024-09-19 374/week @ 2024-09-26 330/week @ 2024-10-03 333/week @ 2024-10-10 499/week @ 2024-10-17 393/week @ 2024-10-24 347/week @ 2024-10-31 331/week @ 2024-11-07 354/week @ 2024-11-14 338/week @ 2024-11-21 191/week @ 2024-11-28 358/week @ 2024-12-05 290/week @ 2024-12-12 177/week @ 2024-12-19 121/week @ 2024-12-26 233/week @ 2025-01-02

900 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
~149K SLoC