req icon indicating copy to clipboard operation
req copied to clipboard

Add update_header

Open wojtekmach opened this issue 4 months ago • 1 comments

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.

wojtekmach avatar Sep 01 '25 20:09 wojtekmach

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.

whatyouhide avatar Sep 02 '25 09:09 whatyouhide