mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-24 09:12:48 +00:00
feat(middleware/correlationid): use x-request-id header if found in request
This commit is contained in:
@@ -10,7 +10,10 @@ import (
|
||||
|
||||
func CorrelationIDHandler(next http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
id := uuid.New().String()
|
||||
id := r.Header.Get(chi_middleware.RequestIDHeader)
|
||||
if len(id) == 0 {
|
||||
id = uuid.New().String()
|
||||
}
|
||||
|
||||
ctx := r.Context()
|
||||
ctx = context.WithValue(ctx, chi_middleware.RequestIDKey, id)
|
||||
|
||||
Reference in New Issue
Block a user