Files
weave-scope/vendor/github.com/richo/GOSHOUT/SHOUT.go
Bryan Boreham 4f75600931 Pin SHOUT library at working version
The version we did have has a bug of not importing 'time'.

Remove other vendor'd copy of SHOUT library which may or may not be used.
2020-12-30 18:30:34 +00:00

47 lines
929 B
Go

package SHOUTCLOUD
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"net/http"
)
type SHOUTREQUEST struct {
INPUT string
}
type SHOUTRESPONSE struct {
INPUT string
OUTPUT string
}
func UPCASE(THING_TO_YELL string) (string, error) {
REQUEST := &SHOUTREQUEST{THING_TO_YELL}
ENCODED, ERR := json.Marshal(REQUEST)
if ERR != nil {
return "", errors.New("COULDN'T MARSHALL THE REQUEST")
}
READER := bytes.NewReader(ENCODED)
// NO TLS, SO MUCH SADNESS.
RESP, ERR := http.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT",
"application/json", READER)
if ERR != nil {
return "", errors.New("REQUEST FAILED CAN'T UPCASE ERROR MESSAGE HALP")
}
BODYBYTES, ERR := ioutil.ReadAll(RESP.Body)
if ERR != nil {
return "", errors.New("COULDN'T READ BODY HALP")
}
var BODY SHOUTRESPONSE
if json.Unmarshal(BODYBYTES, &BODY) != nil {
return "", errors.New("COULDN'T UNPACK RESPONSE")
}
return BODY.OUTPUT, nil
}