Replace/UpsertReplace support

This commit is contained in:
Ian Gulliver
2024-06-23 16:32:28 -07:00
parent 6abf2d051e
commit fd97e6ecca
6 changed files with 89 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
@@ -63,7 +64,8 @@ func do[T any](ctx context.Context, c *Client, method, path string, params url.V
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, fmt.Errorf("http error: %d %s", resp.StatusCode, http.StatusText(resp.StatusCode))
errBody, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("http error: %d %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), string(errBody))
}
dec := json.NewDecoder(resp.Body)