diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-03-18 13:58:08 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-05 12:26:16 +0200 |
| commit | 2d5c7dad599b3f8b70ab07382973c51d1de2193d (patch) | |
| tree | 3ca48a1104f958f896813a4d70093cdc27429133 /src/http.go | |
| parent | 343836597df3efd6f31a68e29ff82b6ec4979f69 (diff) | |
Refactor: Structures changed and added Token refresh function
Diffstat (limited to 'src/http.go')
| -rw-r--r-- | src/http.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/http.go b/src/http.go index 57e5939..1374eed 100644 --- a/src/http.go +++ b/src/http.go @@ -62,6 +62,23 @@ func HTTPGet(url string) ([]byte, error) { return HTTPGetWithOptionalParams(url, nil) } +func HTTPConstructURL(baseURL string, parameters map[string]string) (string, error) { + url, err := url.Parse(baseURL) + + if err != nil { + return "", err + } + + q := url.Query() + + for parameter, value := range parameters { + q.Set(parameter, value) + } + url.RawQuery = q.Encode() + return url.String(), nil +} + + func HTTPGetWithOptionalParams(url string, opts *HTTPOptionalParams) ([]byte, error) { client := &http.Client{} req, reqErr := http.NewRequest(http.MethodGet, url, nil) |
