Expand description
ETags and conditional requests
ETagsmiddleware: tagsGETresponses with anETagderived from the body and answers304 Not Modifiedwhen the client’sIf-None-Matchstill matches. Responses that already carry anETagkeep it.require_if_match: optimistic concurrency for updates. The client sends theETagit last saw asIf-Match; a stale one gets412, a missing one428, so concurrent edits cannot silently overwrite each other.
use ullun::conditional::{etag_for, if_none_match_hits};
let tag = etag_for(b"hello");
assert!(if_none_match_hits(&tag, &tag));
assert!(if_none_match_hits("\"other\", *", &tag));
assert!(!if_none_match_hits("\"other\"", &tag));Structs§
- ETags
- Middleware adding
ETagand304 Not Modifiedhandling toGETresponses
Functions§
- etag_
for - Strong ETag for a body: 64-bit FNV-1a plus the length, e.g.
"2f3c...-5". Stable across processes and releases (unlikeDefaultHasher). - if_
match_ hits If-Matchevaluation: strong comparison, so weak tags never match- if_
none_ match_ hits If-None-Matchevaluation: weak comparison,*matches anything- require_
if_ match - Precondition for updating a resource whose current tag is
current_etag