Skip to content

Commit

Permalink
refactor: refactor HTTP requests to use context package
Browse files Browse the repository at this point in the history
- Add import for `context` package
- Use `http.NewRequestWithContext` instead of `http.NewRequest`

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Sep 27, 2024
1 parent 83d40df commit f23b413
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion expvar_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package expvar

import (
"context"
"net/http"
"net/http/httptest"
"testing"
Expand All @@ -10,7 +11,7 @@ import (
)

func performRequest(r http.Handler, method, path string) *httptest.ResponseRecorder {
req, _ := http.NewRequest(method, path, nil)
req, _ := http.NewRequestWithContext(context.Background(), method, path, nil)
w := httptest.NewRecorder()
r.ServeHTTP(w, req)
return w
Expand Down

0 comments on commit f23b413

Please sign in to comment.