View Source Tesla.Client (tesla v1.13.2)

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.

Types

adapter()

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

middleware()

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

t()

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

Functions

adapter(client)

@spec 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]}

middleware(client)

@spec 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"}]