client.doRequest: improve GoDoc to clarify behavior

Outline that any error returned is a connectivity error and a nil-error
requires the response to be handled (including errors returned in the
response).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-12 23:19:36 +02:00
parent d69fde4c60
commit 2a4f70309d
2 changed files with 12 additions and 0 deletions

View File

@@ -133,6 +133,12 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
}
}
// doRequest sends an HTTP request and returns an HTTP response. It is a
// wrapper around [http.Client.Do] with extra handling to decorate errors.
//
// Otherwise, it behaves identical to [http.Client.Do]; an error is returned
// when failing to make a connection, On error, any Response can be ignored.
// A non-2xx status code doesn't cause an error.
func (cli *Client) doRequest(req *http.Request) (*http.Response, error) {
resp, err := cli.client.Do(req)
if err == nil {