View Source HTTPX (HTTPX v0.1.9)

Simple HTTP(s) client with integrated auth methods.

Summary

Functions

Performs a delete request.

Performs a delete request.

Performs a get request.

Performs a get request.

Performs a request on all IPs associated with the host DNS.

Optimize HTTPX processors.

Performs a patch request, passing the body in the options.

Performs a patch request, passing the body in the options.

Perform a given request.

Performs a post request, passing the body in the options.

Performs a post request, passing the body in the options.

Performs a put request, passing the body in the options.

Performs a post request, passing the body in the options.

Encode a map as query.

Types

@type post_body() ::
  binary()
  | {:urlencoded, map() | keyword()}
  | {:file, String.t()}
  | {:json, term()}
  | {:multipart, list()}

Functions

Link to this function

delete(url, options \\ [])

View Source
@spec delete(
  String.t(),
  keyword()
) :: {:ok, HTTPX.Response.t()} | {:error, term()}

Performs a delete request.

For options see: &request/3.

Link to this function

delete!(url, options \\ [])

View Source
@spec delete!(
  String.t(),
  keyword()
) :: HTTPX.Response.t() | no_return()

Performs a delete request.

For options see: &delete/2.

@spec get(
  String.t(),
  keyword()
) :: {:ok, HTTPX.Response.t()} | {:error, term()}

Performs a get request.

For options see: &request/3.

Link to this function

get!(url, options \\ [])

View Source
@spec get!(
  String.t(),
  keyword()
) :: HTTPX.Response.t() | no_return()

Performs a get request.

For options see: &get/2.

Link to this function

multi_request(method, url, opts \\ [])

View Source
@spec multi_request(term(), String.t(), keyword()) :: %{ok: map(), error: map()}

Performs a request on all IPs associated with the host DNS.

For more information see: request/3.

@spec optimize() :: :ok

Optimize HTTPX processors.

This is automatically called on HTTPX load. So there is no need to call it manually.

The function is idempotent, so there is no harm in calling it.

Link to this function

patch(url, body, options \\ [])

View Source
@spec patch(String.t(), post_body(), keyword()) ::
  {:ok, HTTPX.Response.t()} | {:error, term()}

Performs a patch request, passing the body in the options.

For options see: &request/3.

Link to this function

patch!(url, body, options \\ [])

View Source
@spec patch!(String.t(), post_body(), keyword()) :: HTTPX.Response.t() | no_return()

Performs a patch request, passing the body in the options.

For options see: &patch/3.

@spec perform(HTTPX.Request.t()) :: {:ok, HTTPX.Response.t()} | {:error, term()}

Perform a given request.

Link to this function

post(url, body, options \\ [])

View Source
@spec post(String.t(), post_body(), keyword()) ::
  {:ok, HTTPX.Response.t()} | {:error, term()}

Performs a post request, passing the body in the options.

For options see: &request/3.

Link to this function

post!(url, body, options \\ [])

View Source
@spec post!(String.t(), post_body(), keyword()) :: HTTPX.Response.t() | no_return()

Performs a post request, passing the body in the options.

For options see: &post/3.

Link to this function

put(url, body, options \\ [])

View Source
@spec put(String.t(), post_body(), keyword()) ::
  {:ok, HTTPX.Response.t()} | {:error, term()}

Performs a put request, passing the body in the options.

For options see: &request/3.

Link to this function

put!(url, body, options \\ [])

View Source
@spec put!(String.t(), post_body(), keyword()) :: HTTPX.Response.t() | no_return()

Performs a post request, passing the body in the options.

For options see: &put/3.

@spec query_encode(map()) :: binary()

Encode a map as query.

Link to this function

request(method, url, options \\ [])

View Source
@spec request(term(), String.t(), keyword()) ::
  {:ok, HTTPX.Response.t()} | {:error, term()}

Performs a request.

The given method is used and the url is called.

The following options can be set:

  • :body, the body to send with the request.
  • :params, a map containing query params.
  • :headers, list of header tuples.
  • :settings, options to pass along to :hackney.
  • :fail, will error out any request with a non 2xx response code, when set to true.
  • :auth, set authorization options.
  • :format, set to parse. (Like :json)
  • :retry, set to retry the request. See the retry options.