mojito v0.7.4 Mojito.Base behaviour View Source

Provides a default implementation for Mojito functions.

This module is meant to be use'd in custom modules in order to wrap the functionalities provided by Mojiti. For example, this is very useful to build custom API clients around Mojito:

defmodule CustomAPI do
  use Mojito.Base
end

Link to this section Summary

Link to this section Types

Link to this type

error() View Source
error() :: %Mojito.Error{message: String.t() | nil, reason: any()}

Link to this type

headers() View Source
headers() :: [header()]

Link to this type

method() View Source
method() ::
  :head | :get | :post | :put | :patch | :delete | :options | String.t()

Link to this type

pool_opt() View Source
pool_opt() ::
  {:size, pos_integer()}
  | {:max_overflow, non_neg_integer()}
  | {:pools, pos_integer()}
  | {:strategy, :lifo | :fifo}

Link to this type

pool_opts() View Source
pool_opts() :: [pool_opt() | {:destinations, [{atom(), pool_opts()}]}]

Link to this type

request() View Source
request() :: %Mojito.Request{
  body: String.t() | nil,
  headers: headers() | nil,
  method: method(),
  opts: Keyword.t() | nil,
  url: String.t()
}

Link to this type

request_field() View Source
request_field() ::
  {:method, method()}
  | {:url, String.t()}
  | {:headers, headers()}
  | {:body, String.t()}
  | {:opts, Keyword.t()}

Link to this type

request_kwlist() View Source
request_kwlist() :: [request_field()]

Link to this type

response() View Source
response() :: %Mojito.Response{
  body: String.t(),
  complete: boolean(),
  headers: headers(),
  size: term(),
  status_code: pos_integer()
}

Link to this section Callbacks

Link to this callback

delete(url) View Source
delete(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

delete(url, headers) View Source
delete(url(), headers()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

delete(url, headers, arg2) View Source
delete(url(), headers(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

get(url) View Source
get(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

get(url, headers) View Source
get(url(), headers()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

get(url, headers, arg2) View Source
get(url(), headers(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

head(url) View Source
head(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

head(url, headers) View Source
head(url(), headers()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

head(url, headers, arg2) View Source
head(url(), headers(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

options(url) View Source
options(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

options(url, headers) View Source
options(url(), headers()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

options(url, headers, arg2) View Source
options(url(), headers(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

patch(url) View Source
patch(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

patch(url, headers) View Source
patch(url(), headers()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

patch(url, headers, payload) View Source
patch(url(), headers(), payload()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

patch(url, headers, payload, arg3) View Source
patch(url(), headers(), payload(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

post(url) View Source
post(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

post(url, headers) View Source
post(url(), headers()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

post(url, headers, payload) View Source
post(url(), headers(), payload()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

post(url, headers, payload, arg3) View Source
post(url(), headers(), payload(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

put(url) View Source
put(url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

put(url, headers) View Source
put(url(), headers()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

put(url, headers, payload) View Source
put(url(), headers(), payload()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

put(url, headers, payload, arg3) View Source
put(url(), headers(), payload(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

request(arg0) View Source
request(request() | request_kwlist()) :: {:ok, response()} | {:error, error()}

Link to this callback

request(method, url) View Source
request(method(), url()) :: {:ok, response()} | {:error, error()} | no_return()

Link to this callback

request(method, url, headers) View Source
request(method(), url(), headers()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

request(method, url, headers, body) View Source
request(method(), url(), headers(), body()) ::
  {:ok, response()} | {:error, error()} | no_return()

Link to this callback

request(method, url, headers, body, arg4) View Source
request(method(), url(), headers(), body(), Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()