Refactor - simplify code
This commit is contained in:
@@ -27,29 +27,19 @@ func (c *HttpClient) SendGet(url string, data, out any) error {
|
||||
decoder := json.NewDecoder(res.Body)
|
||||
defer res.Body.Close()
|
||||
|
||||
err = decoder.Decode(&out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return decoder.Decode(&out)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(res.Body)
|
||||
defer res.Body.Close()
|
||||
|
||||
err = decoder.Decode(out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
return decoder.Decode(&out)
|
||||
}
|
||||
|
||||
func (c *HttpClient) sendRequest(url, method string, data any) (*http.Response, error) {
|
||||
|
||||
Reference in New Issue
Block a user