refactor: use http.NewRequestWithContext instead of http.NewRequest (#97)

This commit is contained in:
bestgopher
2023-03-02 14:27:09 +08:00
committed by GitHub
parent de9a632138
commit 58d99eb220
11 changed files with 17 additions and 32 deletions

View File

@@ -40,12 +40,11 @@ func (c *Client) Answers(ctx context.Context, request AnswerRequest) (response A
return
}
req, err := http.NewRequest("POST", c.fullURL("/answers"), bytes.NewBuffer(reqBytes))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.fullURL("/answers"), bytes.NewBuffer(reqBytes))
if err != nil {
return
}
req = req.WithContext(ctx)
err = c.sendRequest(req, &response)
return
}