View Source Tesla.Client (tesla v1.13.0)

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

@type adapter() ::
  module() | {module(), any()} | (Tesla.Env.t() -> Tesla.Env.result())
@type middleware() :: module() | {module(), any()}
@type t() :: %Tesla.Client{
  adapter: Tesla.Env.runtime() | nil,
  fun: term(),
  post: Tesla.Env.stack(),
  pre: Tesla.Env.stack()
}

Functions

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