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

@@ -99,12 +99,11 @@ func (c *Client) CreateCompletion(
}
urlSuffix := "/completions"
req, err := http.NewRequest("POST", c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes))
if err != nil {
return
}
req = req.WithContext(ctx)
err = c.sendRequest(req, &response)
return
}