From 8072daab7a5221842cf823d9b314deb49b9ba6ff Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 28 Jul 2024 22:44:03 +0300 Subject: rename entry to ent --- internal/easyhttp/easyhttp.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'internal/easyhttp') diff --git a/internal/easyhttp/easyhttp.go b/internal/easyhttp/easyhttp.go index ce3d53b..c44cce3 100644 --- a/internal/easyhttp/easyhttp.go +++ b/internal/easyhttp/easyhttp.go @@ -68,7 +68,14 @@ func Post(ctx context.Context, uri, apiKey string, data []byte) ([]byte, error) return []byte{}, fmt.Errorf("%s: %w", uri, err) } - return body, nil + switch resp.StatusCode { + case 200: + return body, nil + case 401: + return body, fmt.Errorf("unauthorized, API key configured?") + default: + return body, fmt.Errorf("unexpected HTTP response code %d", resp.StatusCode) + } } // Submit structure as JSON to API -- cgit v1.2.3