ivar v0.2.0 Ivar.Headers

Ivar.Headers manages the request headers used for a request

Summary

Functions

Puts the given headers into the existing request map

Puts the given value under key into the request headers map

Functions

put(request, headers)
put(map, {tuple | Keyword.t | map}) :: map

Puts the given headers into the existing request map

Args

  • request - the map used to store the map of headers, usually created via Ivar.new/2
  • headers - the headers to be put into the headers map

Headers

  • Key/value tuple - {:header, "value"} or {"header", "value"}
  • List of Key/value tuple - [{:header, "value"}]
  • Keyword list - [header: "value"]
  • Map - %{header: "value"}

Usage

iex> Ivar.Headers.put(%{}, [accept: "application/json"])
%{headers: %{"accept" => "application/json"}}
put(request, key, value)
put(map, {atom | binary}, binary) :: map

Puts the given value under key into the request headers map

Args

  • request - the map used to store the map of headers, usually created via Ivar.new/2
  • key - the header name as string or atom (e.g. :header or "header")
  • value - the header value

Usage

iex> Ivar.Headers.put(%{}, :accept, "application/json")
%{headers: %{"accept" => "application/json"}}