summaryrefslogtreecommitdiff
path: root/internal/easyhttp
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-07-28 22:44:03 +0300
committerPaul Buetow <paul@buetow.org>2024-07-28 22:44:03 +0300
commit8072daab7a5221842cf823d9b314deb49b9ba6ff (patch)
treedf82e769da205811d4347ff8e05527df58fdea74 /internal/easyhttp
parentf36f21e1f1610b76caecbfab844f0462a9ba040c (diff)
rename entry to ent
Diffstat (limited to 'internal/easyhttp')
-rw-r--r--internal/easyhttp/easyhttp.go9
1 files changed, 8 insertions, 1 deletions
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