req
req copied to clipboard
Add update_header
I'm thinking:
maybe_update_header(r, name, fun)
update_header(r, name, default, fun)
update_header!(r, name, fun)
I don't like the maybe_ part though. Alternatively, in update_header/4 passing nil as default or returning nil from fun could mean don't add and delete the header respectively and so we don't need maybe_update_header/3. But we don't treat nil values like that anywhere else so not sure.
I would try to stick as close as possible to Map/Keyword APIs for familiarity. So, update would mean default value + function, update! expects it to be there. Map/Keyword don't have update_if_exists but I believe that would be a good candidate for the maybe_ one.