View Source Tesla.Env (tesla v1.7.0)

This module defines a Tesla.Env.t/0 struct that stores all data related to request/response.

fields

Fields

  • :method - method of request. Example: :get
  • :url - request url. Example: "https://www.google.com"
  • :query - list of query params. Example: [{"param", "value"}] will be translated to ?params=value. Note: query params passed in url (e.g. "/get?param=value") are not parsed to query field.
  • :headers - list of request/response headers. Example: [{"content-type", "application/json"}]. Note: request headers are overridden by response headers when adapter is called.
  • :body - request/response body. Note: request body is overridden by response body when adapter is called.
  • :status - response status. Example: 200
  • :opts - list of options. Example: [adapter: [recv_timeout: 30_000]]

Link to this section Summary

Link to this section Types

@type body() :: any()
@type client() :: Tesla.Client.t()
@type headers() :: [{binary(), binary()}]
@type method() :: :head | :get | :delete | :trace | :options | :post | :put | :patch
@type opts() :: keyword()
@type param() :: binary() | [{binary() | atom(), param()}]
@type query() :: [{binary() | atom(), param()}]
@type result() :: {:ok, t()} | {:error, any()}
@type runtime() ::
  {atom(), atom(), any()}
  | {atom(), atom()}
  | {:fn, (t() -> t())}
  | {:fn, (t(), stack() -> t())}
@type stack() :: [runtime()]
@type status() :: integer() | nil
@type t() :: %Tesla.Env{
  __client__: client(),
  __module__: atom(),
  body: body(),
  headers: headers(),
  method: method(),
  opts: opts(),
  query: query(),
  status: status(),
  url: url()
}
@type url() :: binary()