View Source Tesla.Client (tesla v1.7.0)

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

@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()
}

Link to this section 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

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

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