Sippet.Message.put_new_lazy_header
You're seeing just the function
put_new_lazy_header
, go back to Sippet.Message module for more information.
Specs
Evaluates fun
and puts the result under header
in message
unless
header
is already present.
This function is useful in case you want to compute the value to put under
header
only if header
is not already present (e.g., the value is
expensive to calculate or generally difficult to setup and teardown again).
Examples:
iex> Sippet.Message.build_request(:invite, "sip:foo@bar.com")
...> |> Sippet.Message.put_new_lazy_header(:max_forwards, fn -> 70 end)
...> |> Sippet.Message.put_new_lazy_header(:max_forwards, fn -> 1 end)
%Sippet.Message{body: nil, headers: %{max_forwards: 70},
start_line: %Sippet.Message.RequestLine{method: :invite,
request_uri: %Sippet.URI{authority: "foo@bar.com", headers: nil,
host: "bar.com", parameters: nil, port: 5060, scheme: "sip",
userinfo: "foo"}, version: {2, 0}}, target: nil}