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

#1173 in Network programming

Download history 454/week @ 2024-10-22 314/week @ 2024-10-29 304/week @ 2024-11-05 379/week @ 2024-11-12 377/week @ 2024-11-19 220/week @ 2024-11-26 246/week @ 2024-12-03 394/week @ 2024-12-10 202/week @ 2024-12-17 130/week @ 2024-12-24 208/week @ 2024-12-31 413/week @ 2025-01-07 499/week @ 2025-01-14 626/week @ 2025-01-21 304/week @ 2025-01-28 277/week @ 2025-02-04

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