Skip to main content

handler

Function handler 

Source
pub async fn handler<F, Args>(
    f: Arc<F>,
    __arg1: ArpyRequest<Args>,
) -> impl Responder
where F: FnRemoteBody<Args>, Args: FnRemote,
Expand description

An Actix handler for RPC requests.

Use this when you want more control over the route than RpcApp::http_rpc_route gives.

ยงExample

#[derive(MsgId, Serialize, Deserialize, Debug)]
struct MyAdd(u32, u32);

impl FnRemote for MyAdd {
    type Output = u32;
}

async fn my_add(args: MyAdd) -> u32 {
    args.0 + args.1
}

let ws = WebSocketRouter::new().handle(my_add);

App::new()
    .ws_rpc_route("ws", ws, 1000)
    .http_rpc_route("http", my_add);