salemove_http_client v0.1.0 Salemove.HttpClient

Generic HTTP client built on top of Tesla and used to build specific JSON API HTTP clients with ability to configure them during runtime, using, for example, environment variables.

Configuration options:

  • :base_url - Base URL of service (including schema, i.e. https://api.github.com/)
  • :adapter - HTTP Adapter module, defaults to Tesla.Adapter.Hackney
  • :adapter_options - adapter specific options, see documentation for concrete adapter
  • :json - JSON encoding/decoding options. See Tesla.Middleware.JSON.
  • :stats - StatsD instrumenting options. See Tesla.StatsD for more details.
  • :username - along with :password option adds basic authentication to all requests. See Tesla.Middleware.BasicAuth.
  • :password - see :username.
  • :debug - Turn on/off verbose request/response logging, defaults to false

Example

defmodule Github do
  use Elixir.Salemove.HttpClient, base_url: "https://api.github.com/"

  def user_repos(login) do
    get("/user/" <> login <> "/repos")
  end
end

Link to this section Summary

Types

Client or request-specific options

Link to this section Types

Link to this type options()
options() :: Keyword.t()

Client or request-specific options