From be790b28cc550e7a44f34e94a5f539c16c85342e Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 1 Jun 2021 15:09:24 +0100 Subject: [PATCH] check response code in publisher --- cmd/publisher/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/publisher/main.go b/cmd/publisher/main.go index fc2948d..7fd55db 100644 --- a/cmd/publisher/main.go +++ b/cmd/publisher/main.go @@ -3,6 +3,7 @@ package main import ( "bytes" "encoding/json" + "errors" "fmt" "io" "io/ioutil" @@ -46,6 +47,12 @@ func publishAPI(apiSpec *PublicAPI) error { return err } defer resp.Body.Close() + + if resp.StatusCode != 200 { + b, _ := ioutil.ReadAll(resp.Body) + return errors.New(string(b)) + } + io.Copy(ioutil.Discard, resp.Body) return nil