-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Req.get_header(req_or_resp)
and Req.put_header
#207
Comments
Instead of But then we have two very similar ways: Req.update(req, headers: [accept: "application/json"])
Req.put_headers(req, accept: "application/json") so unsure. |
For the given use case of The benefit of using |
thanks for feedback!
|
Right, which
Staying into a So when you are coding, you can focus on creating functions around the data and have less to do with the permutation + data (in other words, they are separated). For example, people could end up doing the following (nuances, please understand that it depends, just based on my experience): defp put_default_headers(reg, headers) do
Req.update(req, [])
end Chasing the "intent" of avoiding mistakes in terms of what "putting" means and what "putting headers" means. Instead of: defp default_headers do
[]
end
# or even # defp get_default_headers do
# or much closer @default_headers [] This is a simple situation, but overall, the more you separate the permutation from the data, the "easier" (🧂) it becomes to test and combine things (take it with a grain of salt 🧂, again, it depends). Something like that, I found that programmers will end up, in one way or another adding such specialized functions to hide away internal data structure details or avoid those naming situations. 🚲 Bikeshedding 🐑 |
I personally like I'm not overly concerned about the overlap with
|
Req.get_header(req_or_resp)
and Req.put_header
Req.get_header(req_or_resp)
and Req.put_header
Closing in favour of #224. |
For the vast majority of cases people should be fine just using the
Req
module (and looking up doctests inReq.Steps
) so havingReq.get_header
andReq.put_header
(as opposed toReq.Request.*
andReq.Response.*
) would go towards that.Thanks @zachallaun for the suggestion.
Examples:
The text was updated successfully, but these errors were encountered: