Update repo URL
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -18,26 +17,25 @@ func NewHttpClient(baseURL string) *HttpClient {
|
||||
}
|
||||
|
||||
func (c *HttpClient) SendGet(url string, data, out any) error {
|
||||
fmt.Printf("Sending req to: %s%s\n", c.baseURL, url)
|
||||
res, err := c.sendRequest(url, http.MethodGet, data)
|
||||
resp, err := c.sendRequest(url, http.MethodGet, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(res.Body)
|
||||
defer res.Body.Close()
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
|
||||
return decoder.Decode(&out)
|
||||
}
|
||||
|
||||
func (c *HttpClient) SendPost(url string, data, out any) error {
|
||||
res, err := c.sendRequest(url, http.MethodPost, data)
|
||||
resp, err := c.sendRequest(url, http.MethodPost, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(res.Body)
|
||||
defer res.Body.Close()
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
|
||||
return decoder.Decode(&out)
|
||||
}
|
||||
@@ -49,7 +47,6 @@ func (c *HttpClient) sendRequest(url, method string, data any) (*http.Response,
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // FIXME dev mode
|
||||
}
|
||||
|
||||
// Create an HTTP client with the custom transport
|
||||
client := &http.Client{Transport: tr} // FIXME dev mode
|
||||
|
||||
json, err := json.Marshal(&data)
|
||||
@@ -64,10 +61,11 @@ func (c *HttpClient) sendRequest(url, method string, data any) (*http.Response,
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("User-Agent", c.userAgent)
|
||||
res, err := client.Do(req)
|
||||
req.Header.Set("Authorization", "Bearer DupaToken")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user