Commit 5b756e2f authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Fix the WithContext func (#149)

parent 219e9b58
...@@ -550,7 +550,7 @@ func WithSudo(uid interface{}) OptionFunc { ...@@ -550,7 +550,7 @@ func WithSudo(uid interface{}) OptionFunc {
// WithContext runs the request with the provided context // WithContext runs the request with the provided context
func WithContext(ctx context.Context) OptionFunc { func WithContext(ctx context.Context) OptionFunc {
return func(req *http.Request) error { return func(req *http.Request) error {
req = req.WithContext(ctx) *req = *req.WithContext(ctx)
return nil return nil
} }
} }
......
...@@ -140,7 +140,7 @@ func TestCheckResponse(t *testing.T) { ...@@ -140,7 +140,7 @@ func TestCheckResponse(t *testing.T) {
} }
func TestRequestWithContext(t *testing.T) { func TestRequestWithContext(t *testing.T) {
ctx := context.Background() ctx := context.WithValue(context.Background(), interface{}("myKey"), interface{}("myValue"))
req, err := NewClient(nil, "").NewRequest("GET", "test", nil, []OptionFunc{WithContext(ctx)}) req, err := NewClient(nil, "").NewRequest("GET", "test", nil, []OptionFunc{WithContext(ctx)})
if err != nil { if err != nil {
t.Fatalf("Failed to create request: %v", err) t.Fatalf("Failed to create request: %v", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment