Restlax.Client (Restlax v1.0.1)

Copy Markdown View Source

Rest Client builder

Options

  • :base_url - String.t() Base URL, e.g. "https://api.cloudflare.com/client/v4"
  • :encoding - encoding() :json or :form_urlencoded
  • :headers - [{String.t(), String.t()}] Default headers, can be overridden per request
  • :req_options - keyword() Req options that are applied to all requests

Example

defmodule MyClient do
  use Restlax.Client,
    base_url: "https://my-awesome.app/api/v1",
    req_options: [receive_timeout: 30_000]
end

Summary

Types

encoding()

@type encoding() :: :json | :form_url_encoded | :raw

option()

@type option() ::
  {:base_url, String.t()}
  | {:encoding, encoding()}
  | {:headers, [{String.t(), String.t()}]}
  | {:req_options, keyword()}

Functions

request(module, method, path, body, opts, bang)

@spec request(module(), atom(), String.t(), term(), keyword(), boolean()) ::
  {:ok, map()} | map() | no_return()