Honeybadger.HTTPAdapter behaviour (Honeybadger v0.24.1)

View Source

HTTP adapter helper module.

You can configure the HTTP adapter that Honeybadger uses by setting the following option:

http_adapter: Honeybadger.HTTPAdapter.Req

Default options can be set by passing a list of options:

http_adapter: {Honeybadger.HTTPAdapter.Req, [...]}

You can also set the client for the application:

config :honeybadger, :http_adapter, Honeybadger.HTTPAdapter.Req

Usage

defmodule MyApp.MyHTTPAdapter do
  @behaviour Honeybadger.HTTPAdapter

  @impl true
  def request(method, url, body, headers, opts) do
    # ...
  end

  @impl true
  def decode_response_body(response, opts) do
    # ...
  end
end

Summary

Functions

Validates that the configured HTTP adapter's dependencies are available.

Types

body()

@type body() :: binary() | nil

headers()

@type headers() :: [{binary(), binary()}]

method()

@type method() :: :get | :post

Callbacks

decode_response_body(t, t)

request(method, binary, body, headers, t)

@callback request(method(), binary(), body(), headers(), Keyword.t()) ::
  {:ok, map()} | {:error, any()}

Functions

request(method, url, body, headers, opts)

@spec request(atom(), binary(), binary() | nil, list(), Keyword.t()) ::
  {:ok, Honeybadger.HTTPAdapter.HTTPResponse.t()}
  | {:error, Honeybadger.HTTPAdapter.HTTPResponse.t()}
  | {:error, term()}

Makes an HTTP request.

Options

  • :http_adapter - The HTTP adapter to use, defaults to to one of the available adapters (Req is preferred, falling back to Hackney if available)

validate_adapter_availability!()

Validates that the configured HTTP adapter's dependencies are available.

This should be called during application startup to ensure that the configured adapter can be used.