package internal import ( "encoding/json" "io/ioutil" "net/http" "net/url" ) type Status struct { Success bool `json:"success"` Message string `json:"message"` } func ResponseGet(endpoint string) ([]byte, error) { resp, err := http.Get(endpoint) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } return body, err } func ResponsePost(endpoint string, form url.Values) ([]byte, error) { resp, err := http.PostForm(endpoint, form) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } return body, err } func ResponseStatus(endpoint string, form url.Values) (*Status, error) { resp, err := ResponsePost(endpoint, form) if err != nil { return nil, err } status := &Status{} err = json.Unmarshal(resp, &status) if err != nil { return nil, err } return status, nil }