Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 67b0b54eea |
@@ -27,29 +27,19 @@ func (c *HttpClient) SendGet(url string, data, out any) error {
|
|||||||
decoder := json.NewDecoder(res.Body)
|
decoder := json.NewDecoder(res.Body)
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
err = decoder.Decode(&out)
|
return decoder.Decode(&out)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HttpClient) SendPost(url string, data, out any) (any, error) {
|
func (c *HttpClient) SendPost(url string, data, out any) error {
|
||||||
res, err := c.sendRequest(url, http.MethodPost, data)
|
res, err := c.sendRequest(url, http.MethodPost, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder := json.NewDecoder(res.Body)
|
decoder := json.NewDecoder(res.Body)
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
err = decoder.Decode(out)
|
return decoder.Decode(&out)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return out, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HttpClient) sendRequest(url, method string, data any) (*http.Response, error) {
|
func (c *HttpClient) sendRequest(url, method string, data any) (*http.Response, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user