Tesla.get_header
You're seeing just the function
get_header
, go back to Tesla module for more information.
Specs
get_header(Tesla.Env.t(), binary()) :: binary() | nil
Returns value of header specified by key
from :headers
field in Tesla.Env
.
Examples
# non existing header
iex> env = %Tesla.Env{headers: [{"server", "Cowboy"}]}
iex> Tesla.get_header(env, "some-key")
nil
# existing header
iex> env = %Tesla.Env{headers: [{"server", "Cowboy"}]}
iex> Tesla.get_header(env, "server")
"Cowboy"
# first of multiple headers with the same name
iex> env = %Tesla.Env{headers: [{"cookie", "chocolate"}, {"cookie", "biscuits"}]}
iex> Tesla.get_header(env, "cookie")
"chocolate"