require Logger
@type t :: __MODULE__
+ @type method() :: :get | :post | :put | :delete | :head
@doc """
Performs GET request.
def get(nil, _, _), do: nil
def get(url, headers, options), do: request(:get, url, "", headers, options)
+ @spec head(Request.url(), Request.headers(), keyword()) :: {:ok, Env.t()} | {:error, any()}
+ def head(url, headers \\ [], options \\ []), do: request(:head, url, "", headers, options)
+
@doc """
Performs POST request.
Builds and performs http request.
# Arguments:
- `method` - :get, :post, :put, :delete
+ `method` - :get, :post, :put, :delete, :head
`url` - full url
`body` - request body
`headers` - a keyworld list of headers, e.g. `[{"content-type", "text/plain"}]`
`{:ok, %Tesla.Env{}}` or `{:error, error}`
"""
- @spec request(atom(), Request.url(), String.t(), Request.headers(), keyword()) ::
+ @spec request(method(), Request.url(), String.t(), Request.headers(), keyword()) ::
{:ok, Env.t()} | {:error, any()}
def request(method, url, body, headers, options) when is_binary(url) do
uri = URI.parse(url)