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

#1057 in Network programming

Download history 351/week @ 2024-11-17 264/week @ 2024-11-24 208/week @ 2024-12-01 416/week @ 2024-12-08 189/week @ 2024-12-15 159/week @ 2024-12-22 162/week @ 2024-12-29 402/week @ 2025-01-05 450/week @ 2025-01-12 642/week @ 2025-01-19 379/week @ 2025-01-26 316/week @ 2025-02-02 384/week @ 2025-02-09 298/week @ 2025-02-16 400/week @ 2025-02-23 335/week @ 2025-03-02

1,468 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