API Reference Restlax v0.1.0

Modules

Rest Client builder

Options

  • :adapter - module() One of the Tesla Adapters or your own customized adapter
  • :adapter_opts - keyword() options for the adapter
  • :logger_opts - keyword() options for Tesla.Middleware.Logger
  • :base_url - String.t() Base URL, e.g. "https://api.cloudflare.com/client/v4"
  • :encoding - encoding() :json or :form_urlencoded
  • :encoding_opts - keyword() options for Tesla.Middleware.JSON or Tesla.Middle.FormUrlencoded
  • :headers - [{String.t(), String.t()}] Default headers, can be overridden per request

Example

defmodule MyClient do
  use Restlax.Client,
    base_url: "https://my-awesome.app/api/v1"
    adapter: Tesla.Adapter.Hackney
end

Note: You may pick an adapter directly like in the above code. However, it's preferred to not pick one if your API client is a library. Leaving it out allows the users of your library to choose one for themselves.

Rest Resource builder

Options

  • :endpoint - required, string
  • :singular - defaults to false, boolean
  • :only - list of default actions to generate, defaults to [:index, :show, :create, :update, :delete]
  • :except - list of default actions to exclude, defaults to []
  • :create_method - HTTP verb to use for create action, defaults to :post, sometimes :put is used
  • :update_method - HTTP verb to use for update action, defaults to :put, a common alternative is :patch

Example

defmodule MyResource do
  use Restlax.Resource,
    endpoint: "my-resource"
end

^ This creates