43 lines
682 B
Go
43 lines
682 B
Go
package internal
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
type Status struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
}
|