SmolBox.Transport behaviour (SmolBox v0.1.0)

Copy Markdown View Source

Host-selected transport extension point. No callback may retry mutations.

Implementations must validate HTTP status and media type, cap bodies before decoding, and redact failures. A returned error after possible dispatch cannot authorize replay. The default Req implementation is exercised against actual HTTP peers; replacing it transfers those obligations to the host adapter.

Summary

Types

request()

@type request() :: %{
  method: :get | :post | :put | :delete,
  path: String.t(),
  body: binary(),
  content_type: String.t(),
  accept: String.t(),
  max_bytes: pos_integer(),
  mode:
    :buffer
    | :empty
    | {:sse, pos_integer(), (SmolBox.Wire.SSE.event() -> any()) | nil}
}

Callbacks

request(t, request)

@callback request(SmolBox.Worker.t(), request()) ::
  {:ok, binary() | SmolBox.Result.t()} | {:error, SmolBox.Error.t()}