README editted, reutrn error if got 404 and return error in device constructor

This commit is contained in:
yakovlevdmv
2018-04-07 18:22:03 +03:00
parent 1aee7f15e3
commit 4966762ce0
3 changed files with 59 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ import (
"net/http"
"bytes"
"io/ioutil"
"github.com/pkg/errors"
"strconv"
)
func SendSoap(endpoint, message string) (string, error) {
@@ -13,10 +15,15 @@ func SendSoap(endpoint, message string) (string, error) {
if err != nil {
return "", err
}
if resp.StatusCode != http.StatusOK {
return "", errors.New("error: got HTTP response status " + strconv.Itoa(resp.StatusCode))
}
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
//log.Println(resp.StatusCode)
return string(b),nil
}