ivar v0.8.1 Ivar
Ivar is the top level module used to compose HTTP requests.
Summary
Functions
Creates a new request map for the given HTTP method
and url
and merges the
specified opts
into the application level options defined in the config.exs
Delegates to Ivar.Auth.put/3
Delegates to Ivar.Body.put/3
Delegates to Ivar.Files.put/2
Delegates to Ivar.Headers.put/2
Delegates to Ivar.QueryString.put/2
Sends the given HTTP request
Receives the result of Ivar.send/1
and attempts to decode the response body using the
content-type
header included in the HTTP response
Functions
Creates a new request map for the given HTTP method
and url
and merges the
specified opts
into the application level options defined in the config.exs
Args
method
- the HTTP method as an atom (:get
,:post
,:delete
, etc…)url
- a binary containing the full url (e.g.https://example.com
)opts
- keyword list containing any validHTTPoison
options
Usages
Ivar.new(:get, "https://example.com", [timeout: 10_000])
%{method: :get, url: "https://example.com", opts: [timeout: 10_000]}
Delegates to Ivar.Auth.put/3
Delegates to Ivar.Body.put/3
Delegates to Ivar.Files.put/2
Delegates to Ivar.Headers.put/2
put_query_string(map, list | Keyword.t | map) :: map | {:error, binary}
Delegates to Ivar.QueryString.put/2
Sends the given HTTP request
Args
request
- the map containing the request options to send, usually created viaIvar.new/2
Usage
Ivar.new(:get, "https://example.com")
|> Ivar.send
# {:ok, %HTTPoison.Response{}}
Receives the result of Ivar.send/1
and attempts to decode the response body using the
content-type
header included in the HTTP response
Args
response
- an HTTPoison success or failure response
Usage
Ivar.new(:get, "https://example.com")
|> Ivar.send
|> Ivar.unpack
# {"<!doctype html><html>...", %HTTPoison.Response{}}