RouteHandler

Trait RouteHandler 

Source
pub trait RouteHandler: Send + Sync {
    // Required methods
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        request: JsonRpcRequest,
        ctx: RequestContext,
    ) -> Pin<Box<dyn Future<Output = ServerResult<JsonRpcResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn can_handle(&self, method: &str) -> bool;

    // Provided method
    fn metadata(&self) -> RouteMetadata { ... }
}
Expand description

Route handler trait for custom routes

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, request: JsonRpcRequest, ctx: RequestContext, ) -> Pin<Box<dyn Future<Output = ServerResult<JsonRpcResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle the request

Source

fn can_handle(&self, method: &str) -> bool

Check if this handler can handle the request

Provided Methods§

Source

fn metadata(&self) -> RouteMetadata

Get handler metadata

Implementors§