Keep only a short, plain request ID; make others up at random
check / check (push) Failing after 2s

pixa's own RequestID middleware replaces chi's and the response-header
middleware. It keeps a request's own X-Request-Id only when it is at
most 64 letters, digits, '-', '_' or '.', so an over-long or odd value
is never sent back or upstream, and otherwise makes a random ID with
crypto/rand, which tells nothing about the host or how many requests
pixa served. It stores the ID under chi's RequestIDKey, where the
logging middleware, the handlers and the fetcher read it.

Model: opus-5-5
This commit is contained in:
2026-10-04 09:44:47 +00:00
parent 6f7007a0ea
commit c1c28204a1
5 changed files with 35 additions and 19 deletions
@@ -11,7 +11,7 @@ import (
)
// TestFetchSendsRequestID verifies that a fetch sends the ID of the request
// it serves, which chi's RequestID middleware stores in the request context,
// it serves, which the RequestID middleware stores in the request context,
// to the upstream host as X-Request-Id, so the fetch can be found in that
// host's logs.
func TestFetchSendsRequestID(t *testing.T) {