Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

JSON-RPC envelope → RpcApi::dispatch adapter.

Given a raw JsonRpcRequest<serde_json::Value> and an impl RpcApi, produce a fully-formed JsonRpcResponse<serde_json::Value> suitable for return to the client. Wraps:

  1. The method-not-found check (via the method registry).
  2. The RpcApi::dispatch call itself, which the API implementor owns.
  3. Panic catching (converts panics to InternalError envelopes).
  4. The response-envelope assembly (success vs error body).

Functions§

dispatch_envelope
Top-level dispatch.
error_envelope
Build an error envelope by-hand. Useful for middleware that rejects before dispatch runs (rate limit, unknown role, etc.).