Skip to content

Instantly share code, notes, and snippets.

View 0xpr03's full-sized avatar
💭
I may be slow to respond.

Proc 0xpr03

💭
I may be slow to respond.
  • Berlin
View GitHub Profile
@0xpr03
0xpr03 / bridge.rs
Last active October 4, 2019 00:11
Jsonrpc-Core to Actix-Web bridge actix-web 1.0
/// Handle jsonrpc-core IOHandler stuff in actix
/// Based on https://github.com/paritytech/jsonrpc/blob/9360dc86e9c02e65e858ee7816c5ce6e04f18aef/http/src/handler.rs#L415
fn jsonrpc_websocket_bridge(
(data, req): (web::Json<Request>, web::Data<JsonrpcState>),
) -> impl Future<Item = HttpResponse, Error = WebError> {
req.handle_rpc_request(data.into_inner())
.map(|res| match res {
Some(v) => HttpResponse::Ok().json(v),
e => {
error!("Invalid response for request: {:?}", e);