Bloccs.Effects.HTTP.Req (bloccs v0.1.1)

Copy Markdown View Source

Real HTTP backend built on Req.

Select it in production with:

config :bloccs, :effect_backends, http: Bloccs.Effects.HTTP.Req

The declared [effects].http allowlist is enforced by Bloccs.Effects.HTTP.Allowlist before any request leaves the VM — the same check the mock uses — so the capability guarantee is identical to test runs. A denied call raises Bloccs.Effects.Denied (caught by the runtime and turned into a failed message), matching the mock's behavior.

Extra Req options (timeouts, retries, a test adapter/plug, auth headers) can be supplied globally:

config :bloccs, Bloccs.Effects.HTTP.Req, req_options: [retry: :transient]

Responses with a 2xx status resolve to {:ok, body} (a decoded JSON object is a map); non-2xx resolves to {:error, {:http_status, status, body}}; a transport failure to {:error, exception}.

Summary

Types

t()

@type t() :: %Bloccs.Effects.HTTP.Req{
  allow: [String.t()],
  methods: [String.t()],
  options: keyword()
}