Update GOSHOUT package used in example

This commit is contained in:
Bryan Boreham
2021-03-17 10:15:09 +00:00
parent b321f1c1e3
commit ca9e28e730
4 changed files with 12 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import (
"errors"
"io/ioutil"
"net/http"
"time"
)
type SHOUTREQUEST struct {
@@ -25,13 +26,19 @@ func UPCASE(THING_TO_YELL string) (string, error) {
}
READER := bytes.NewReader(ENCODED)
CLIENT := &http.Client{
Timeout:time.Second * 20,
}
// NO TLS, SO MUCH SADNESS.
RESP, ERR := http.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT",
RESP, ERR := CLIENT.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT",
"application/json", READER)
if ERR != nil {
return "", errors.New("REQUEST FAILED CAN'T UPCASE ERROR MESSAGE HALP")
}
defer RESP.Body.Close()
BODYBYTES, ERR := ioutil.ReadAll(RESP.Body)
if ERR != nil {
return "", errors.New("COULDN'T READ BODY HALP")