Skip to content

0xdeafbeef/axum-jrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages