Safe methods (GET, HEAD): calls inner.serve(req) first, since
the response's ETag / Last-Modified are the validators, then
rewrites a 2xx to 304 / 412 when a precondition fails. Error
responses are passed through untouched.
Unsafe methods (PUT, POST, DELETE, ...): preconditions exist to
stop a lost update, so they must be checked before the handler
changes anything. With a :data:ValidatorLookup (see
:meth:with_validators) the current validators are looked up
first and a failing request gets 412 without reaching Inner.
Without one this middleware cannot know the current state, and it
passes the request and response through unchanged: the handler must
check If-Match itself. Evaluating afterwards -- what this used
to do -- ran the write and then told the client it had failed.
The middleware never mutates the Inner response when all
preconditions pass — pass-through is byte-identical so a cache
revalidation downstream sees the same headers as a non-cached
response.
Toggles:
auto_etag (default False) — when the inner response
has no ETag, generate a weak one via fnv1a_etag
before evaluating If-None-Match / If-Match.
Example:
var c = Conditional[Router](Router())
var c2 = Conditional[Router].with_auto_etag(Router())
var c3 = Conditional[Router].with_validators(Router(), lookup_doc)
comptime BodyType = InlineBody
The Body impl this handler authors its response with.