Instream v0.18.0 Instream.Query.Headers View Source

Header Utility.

Link to this section Summary

Functions

Assembles the headers for a query

Assembles headers for basic authentication

Assembles headers for response encoding

Link to this section Functions

Link to this function assemble(config, options \\ []) View Source
assemble(Keyword.t(), Keyword.t()) :: list()

Assembles the headers for a query.

Link to this function assemble_auth(auth) View Source
assemble_auth(Keyword.t()) :: list()

Assembles headers for basic authentication.

Will return an empty list if query authentication is configured. Will return an empty list if either username of password is missing.

Usage

iex> assemble_auth([ method: :query ])
[]

iex> assemble_auth([ username: "user" ])
[]
iex> assemble_auth([ password: "pass" ])
[]

iex> assemble_auth([ username: "user", password: "pass" ])
[{"Authorization", "Basic dXNlcjpwYXNz"}]
Link to this function assemble_encoding(atom) View Source
assemble_encoding(nil | atom()) :: list()

Assembles headers for response encoding.

Usage

iex> assemble_encoding(nil)
[]

# not handled here...
iex> assemble_encoding(:raw)
[]

iex> assemble_encoding(:csv)
[{"Accept", "application/csv"}]

iex> assemble_encoding(:json)
[{"Accept", "application/json"}]