mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
e2e: fix trace_sync http handler registration (#9644)
* Avoid a global http server so that multiple test runs aren't registering global http handlers and causing a panic * gofmt
This commit is contained in:
@@ -52,7 +52,11 @@ func (ts *TracingSink) Started() <-chan struct{} {
|
||||
|
||||
// Initialize an http handler that writes all requests to a file.
|
||||
func (ts *TracingSink) initializeSink() {
|
||||
ts.server = &http.Server{Addr: ts.endpoint}
|
||||
mux := &http.ServeMux{}
|
||||
ts.server = &http.Server{
|
||||
Addr: ts.endpoint,
|
||||
Handler: mux,
|
||||
}
|
||||
defer func() {
|
||||
if err := ts.server.Close(); err != nil {
|
||||
log.WithError(err).Error("Failed to close http server")
|
||||
@@ -69,8 +73,7 @@ func (ts *TracingSink) initializeSink() {
|
||||
log.WithError(err).Error("Could not close stdout file")
|
||||
}
|
||||
}
|
||||
|
||||
http.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) {
|
||||
mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) {
|
||||
if err := captureRequest(stdOutFile, r); err != nil {
|
||||
log.WithError(err).Error("Failed to capture http request")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user