Skip to content

Commit

Permalink
fix: datarace
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 23, 2024
1 parent c5db4ba commit 1086ddf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/api/common/middlewares_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ type responseWriter struct {
headerWritten bool
}

func (r *responseWriter) Header() http.Header {
r.Lock()
defer r.Unlock()

return r.ResponseWriter.Header()
}

func (r *responseWriter) Write(bytes []byte) (int, error) {
r.Lock()
defer r.Unlock()
Expand Down Expand Up @@ -83,7 +90,7 @@ func Timeout(configuration TimeoutConfiguration) func(h http.Handler) http.Handl
}()
defer close(done)

h.ServeHTTP(w, r.WithContext(newRequestContext))
h.ServeHTTP(rw, r.WithContext(newRequestContext))
})
}
}

0 comments on commit 1086ddf

Please sign in to comment.