mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-13 19:45:26 +00:00
check response code in publisher
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user