Trait jsonrpc_core::middleware::Middleware
source · pub trait Middleware<M: Metadata>: Send + Sync + 'static {
type Future: Future<Item = Option<Response>, Error = ()> + Send + 'static;
type CallFuture: Future<Item = Option<Output>, Error = ()> + Send + 'static;
fn on_request<F, X>(
&self,
request: Request,
meta: M,
next: F
) -> Either<Self::Future, X>
where
F: FnOnce(Request, M) -> X + Send,
X: Future<Item = Option<Response>, Error = ()> + Send + 'static,
{ ... }
fn on_call<F, X>(
&self,
call: Call,
meta: M,
next: F
) -> Either<Self::CallFuture, X>
where
F: FnOnce(Call, M) -> X + Send,
X: Future<Item = Option<Output>, Error = ()> + Send + 'static,
{ ... }
}
Expand description
RPC middleware
Required Associated Types
Provided Methods
sourcefn on_request<F, X>(
&self,
request: Request,
meta: M,
next: F
) -> Either<Self::Future, X>where
F: FnOnce(Request, M) -> X + Send,
X: Future<Item = Option<Response>, Error = ()> + Send + 'static,
fn on_request<F, X>(
&self,
request: Request,
meta: M,
next: F
) -> Either<Self::Future, X>where
F: FnOnce(Request, M) -> X + Send,
X: Future<Item = Option<Response>, Error = ()> + Send + 'static,
Method invoked on each request. Allows you to either respond directly (without executing RPC call) or do any additional work before and/or after processing the request.
sourcefn on_call<F, X>(
&self,
call: Call,
meta: M,
next: F
) -> Either<Self::CallFuture, X>where
F: FnOnce(Call, M) -> X + Send,
X: Future<Item = Option<Output>, Error = ()> + Send + 'static,
fn on_call<F, X>(
&self,
call: Call,
meta: M,
next: F
) -> Either<Self::CallFuture, X>where
F: FnOnce(Call, M) -> X + Send,
X: Future<Item = Option<Output>, Error = ()> + Send + 'static,
Method invoked on each call inside a request.
Allows you to either handle the call directly (without executing RPC call).