View Source Snap.HTTPClient behaviour (Snap v0.7.0)

Behaviour for the HTTP client used by the Snap.Cluster.

By default, it uses the Snap.HTTPClient.Adapters.Finch for making requests.

You can configure the Cluster with your own adapter:

config :my_app, MyApp.Cluster,
  http_client_adapter: MyHTTPClientAdapter

The adapter can be configured passing a tuple:

config :my_app, MyApp.Cluster,
  http_client_adapter: {MyHTTPClientAdapter, some_config_for_adapter: "config_value"}

Link to this section Summary

Callbacks

Returns a specification to start this module under the Snap supervisor tree.

Executes the request with the configured adapter.

Link to this section Types

@type body() :: iodata()
@type child_spec() :: Supervisor.child_spec() | {module(), Keyword.t()} | module()
@type headers() :: [{key :: String.t(), value :: String.t()}]
@type method() :: :get | :post | :put | :delete
@type t() :: module()
@type url() :: String.t()

Link to this section Callbacks

@callback child_spec(config :: Keyword.t()) :: child_spec() | :skip

Returns a specification to start this module under the Snap supervisor tree.

If the adapter doesn't need to start in the supervisor tree, you can return :skip.

Link to this callback

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

View Source
@callback request(
  cluster :: module(),
  method :: atom(),
  url(),
  headers(),
  body(),
  opts :: Keyword.t()
) :: {:ok, Snap.HTTPClient.Response.t()} | {:error, Snap.HTTPClient.Error.t()}

Executes the request with the configured adapter.

Link to this section Functions

Link to this function

request(cluster, method, url, headers, body, opts \\ [])

View Source