From 67b8e82457a2f2aaf472b28f5c9fd15d9b25e51e Mon Sep 17 00:00:00 2001 From: ckt1031 <65409152+ckt1031@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:15:30 +0800 Subject: [PATCH] fix: billing status code check --- controller/channel-billing.go | 3 +++ controller/channel-test.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/controller/channel-billing.go b/controller/channel-billing.go index 31c9a133..3621b012 100644 --- a/controller/channel-billing.go +++ b/controller/channel-billing.go @@ -96,6 +96,9 @@ func GetResponseBody(method, url string, channel *model.Channel, headers http.He if err != nil { return nil, err } + if res.StatusCode != http.StatusOK { + return nil, fmt.Errorf("status code: %d", res.StatusCode) + } body, err := io.ReadAll(res.Body) if err != nil { return nil, err diff --git a/controller/channel-test.go b/controller/channel-test.go index 0469019a..84197dfd 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -55,7 +55,7 @@ func testChannel(channel *model.Channel, request ChatRequest) error { return err } - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { return errors.New("invalid status code: " + strconv.Itoa(resp.StatusCode)) }