Skip to content

Commit

Permalink
Use maps for request header examples (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
florish authored Oct 5, 2023
1 parent 1583363 commit 01ff077
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/req.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ defmodule Req do
* `:url` - the request URL.
* `:headers` - the request headers. The header names should be downcased.
* `:headers` - the request headers as a `{key, value}` enumerable (e.g. map, keyword list).
The header names should be downcased.
The headers are automatically encoded using these rules:
Expand Down Expand Up @@ -432,15 +434,15 @@ defmodule Req do
Passing `:headers` will automatically encode and merge them:
iex> req = Req.new(headers: [point_x: 1])
iex> req = Req.update(req, headers: [point_y: 2])
iex> req = Req.new(headers: %{point_x: 1})
iex> req = Req.update(req, headers: %{point_y: 2})
iex> req.headers
%{"point-x" => ["1"], "point-y" => ["2"]}
The same header names are overwritten however:
iex> req = Req.new(headers: [authorization: "bearer foo"])
iex> req = Req.update(req, headers: [authorization: "bearer bar"])
iex> req = Req.new(headers: %{authorization: "bearer foo"})
iex> req = Req.update(req, headers: %{authorization: "bearer bar"})
iex> req.headers
%{"authorization" => ["bearer bar"]}
Expand Down

0 comments on commit 01ff077

Please sign in to comment.