Tesla.Client (tesla v1.5.1) View Source

Link to this section Summary

Functions

Returns the client's adapter in the same form it was provided. This can be used to copy an adapter from one client to another.

Returns the client's middleware in the same form it was provided. This can be used to copy middleware from one client to another.

Link to this section Types

Specs

adapter() ::
  module() | {module(), any()} | (Tesla.Env.t() -> Tesla.Env.result())

Specs

middleware() :: module() | {module(), any()}

Specs

t() :: %Tesla.Client{
  adapter: Tesla.Env.runtime() | nil,
  fun: term(),
  post: Tesla.Env.stack(),
  pre: Tesla.Env.stack()
}

Link to this section Functions

Specs

adapter(t()) :: adapter()

Returns the client's adapter in the same form it was provided. This can be used to copy an adapter from one client to another.

Examples

iex> client = Tesla.client([], {Tesla.Adapter.Hackney, [recv_timeout: 30_000]})
iex> Tesla.Client.adapter(client)
{Tesla.Adapter.Hackney, [recv_timeout: 30_000]}

Specs

middleware(t()) :: [middleware()]

Returns the client's middleware in the same form it was provided. This can be used to copy middleware from one client to another.

Examples

iex> middleware = [Tesla.Middleware.JSON, {Tesla.Middleware.BaseUrl, "https://api.github.com"}]
iex> client = Tesla.client(middleware)
iex> Tesla.Client.middleware(client)
[Tesla.Middleware.JSON, {Tesla.Middleware.BaseUrl, "https://api.github.com"}]