cowboy icon indicating copy to clipboard operation
cowboy copied to clipboard

REST generate_etag documentation

Open mbj4668 opened this issue 4 years ago • 4 comments

The documentation for generate_etag says:

Result  :: binary() | {weak | strong, binary()}
Default  - no etag value

I think it should be:

Result  :: undefined | binary() | {weak | strong, binary()}
Default :: undefined

Returning undefined seems to work, and I have a use case where I need to do this.

mbj4668 avatar Oct 01 '20 09:10 mbj4668

You conditionally generate an etag?

essen avatar Oct 01 '20 09:10 essen

My use case is that I have a REST callback module that handles different resources, and for some of them I can't generate an etag.

In general I like the API where I can implement the default behavior explicitly, and not just by not implementing the function. It is more flexible.

mbj4668 avatar Oct 01 '20 09:10 mbj4668

Asking only to make sure there's a use case for this.

I have no problem with adding undefined along with a test. The expires callback also allows undefined explicitly.

essen avatar Oct 01 '20 09:10 essen

Great, thanks!

mbj4668 avatar Oct 01 '20 10:10 mbj4668

OK for the etag we want to call generate_etag only once, but if it's currently undefined we call the function. So the only way to make it work as intended is make sure that when the function returns undefined we mark the etag as no_call. I will add a test first.

essen avatar Jan 16 '24 14:01 essen

Done. Closing, thanks!

essen avatar Jan 16 '24 15:01 essen