0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

REST: Allow generate_etag to return undefined

This allows conditionally generating an etag.
This commit is contained in:
Loïc Hoguin 2024-01-16 16:28:52 +01:00
parent ec12c2f051
commit defce46fdf
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
4 changed files with 29 additions and 2 deletions

View file

@ -379,7 +379,7 @@ and that the request shouldn't be repeated.
----
generate_etag(Req, State) -> {Result, Req, State}
Result :: binary() | {weak | strong, binary()}
Result :: binary() | {weak | strong, binary()} | undefined
Default - no etag value
----
@ -389,6 +389,10 @@ When a binary is returned, the value is automatically
parsed to a tuple. The binary must be in the same
format as the etag header, including quotes.
It is possible to conditionally generate an etag.
When no etag can be generated, `undefined` should
be returned.
=== is_authorized
[source,erlang]
@ -730,6 +734,9 @@ listed here, like the authorization header.
== Changelog
* *2.11*: The `generate_etag` callback can now return
`undefined` to conditionally avoid generating
an etag.
* *2.9*: An `AcceptCallback` can now return `{created, URI}` or
`{see_other, URI}`. The return value `{true, URI}`
is deprecated.