Loading
feat(v2/httpserver): add CorrelationIDMiddleware
Summary
- Adds
CorrelationIDMiddlewaretov2/httpserverthat reads theX-Request-IDrequest header, generates a UUID when absent or whitespace-only, injects the ID into the request context viacorrelation.InjectToContext, and echoes it as aX-Request-IDresponse header - Wires the middleware unconditionally as the outermost layer in
NewWithConfig, ensuring the correlation ID is available to the tracing middleware, access logger, and all downstream handlers - Fixes the long-standing gap where
correlation_idwas always empty in access logs for requests from GitLab services
Test Plan
-
go test ./httpserver/...passes (20 tests including 3 new subtests for the middleware and 1 integration wiring test) - Access logs now include
correlation_idfor requests carrying aX-Request-IDheader - Requests without the header receive a generated UUID echoed in the response
Edited by Elliot Forbes