summaryrefslogtreecommitdiff
path: root/src/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.go')
-rw-r--r--src/http.go17
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)