- HTTP Client module
defmodule Your.HttpClient do
@behaviour Scratcher.HttpClient
def request(method, url, body, headers, http_opts) do
# use hackney, httpoison, httpotion...
{:ok, %{status_code: 200, body: "..."}}
end
end
- Your Application's Config
config :your_module, http_client: Your.HttpClient
- Your Application/Module
defmodule YourModule do
@http_client Application.fetch_env!(:your_module) |> Keyword.fetch!(:http_client)
def request(method, url, body, headers, http_opts) do
@http_client.request(method, url, body, headers, http_opts)
end
end