Urchin.Dispatcher (Urchin v0.2.0)

Copy Markdown View Source

Routes decoded JSON-RPC requests to Urchin.Server callbacks and shapes their return values into JSON-RPC result maps.

A method is only honoured when the server module exports the matching callback; otherwise a JSON-RPC "method not found" error is returned. User exceptions are rescued and converted to errors so transport processes never crash on handler bugs.

Summary

Functions

Handles an operational (post-initialization) request, returning {:ok, result_map} or {:error, Urchin.Error.t()}.

Handles an initialize request.

Functions

handle_request(server, method, params, ctx)

@spec handle_request(module(), String.t(), map(), Urchin.Context.t()) ::
  {:ok, map()} | {:error, Urchin.Error.t()}

Handles an operational (post-initialization) request, returning {:ok, result_map} or {:error, Urchin.Error.t()}.

initialize(server, params, ctx)

@spec initialize(module(), map(), Urchin.Context.t()) ::
  {:ok, map(), map()} | {:error, Urchin.Error.t()}

Handles an initialize request.

Returns {:ok, result_map, session_meta} where session_meta carries the negotiated protocol version and the client's declared info/capabilities, or {:error, Urchin.Error.t()}.