Bunnyx.HTTP (Bunnyx v0.3.0)

Copy Markdown View Source

Low-level HTTP layer. All API modules go through request/4 — they never call Req directly. You shouldn't need to use this module unless you're extending Bunnyx with unsupported endpoints.

Telemetry

The following telemetry events are emitted:

  • [:bunnyx, :request, :start] — before the request is sent. Measurements: %{system_time: integer}. Metadata: %{method: atom, path: String.t}.

  • [:bunnyx, :request, :stop] — after a successful response. Measurements: %{duration: integer} (native time units). Metadata: %{method: atom, path: String.t, status: integer}.

  • [:bunnyx, :request, :exception] — on transport error. Measurements: %{duration: integer}. Metadata: %{method: atom, path: String.t, kind: :error, reason: term}.

Summary

Functions

Performs an HTTP request against the bunny.net API.

Types

method()

@type method() :: :get | :head | :post | :put | :patch | :delete

Functions

request(req, method, path, opts \\ [])

@spec request(Req.Request.t(), method(), String.t(), keyword()) ::
  {:ok, term()} | {:error, Bunnyx.Error.t()}

Performs an HTTP request against the bunny.net API.

Options

In addition to standard Req options (:body, :json, :params, :headers), the following Bunnyx-specific options are supported:

  • :return_headers — return {:ok, {body, headers}} instead of {:ok, body}
  • :receive_timeout — per-request receive timeout in milliseconds

HEAD requests always return headers only.