Monero v0.9.0 Monero.Request.HttpClient behaviour View Source

Specifies expected behaviour of an http client

Monero allows you to use your http client of choice, provided that it can be coerced into complying with this module’s specification.

The default is :hackney.

Example

Here for example is the code required to make HTTPotion comply with this spec.

In your config you would do:

config :monero,
  http_client: Monero.Request.HTTPotion
defmodule Monero.Request.HTTPotion do
  @behaviour Monero.Request.HttpClient
  def request(method, url, body, headers) do
    {:ok, HTTPotion.request(method, url, [body: body, headers: headers, ibrowse: [headers_as_is: true]])}
  end
end

Link to this section Summary

Link to this section Types

Link to this type http_method() View Source
http_method() :: :get | :post | :put | :delete

Link to this section Callbacks

Link to this callback request(method, url, req_body, headers, http_opts) View Source
request(method :: http_method, url :: binary, req_body :: binary, headers :: [{binary, binary}, ...], http_opts :: term) ::
  {:ok, %{status_code: pos_integer, body: binary}} |
  {:error, %{reason: any}}