Skip to content

Commit

Permalink
HttpGet minor bug fixed (by param exist or not)
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldnet committed Apr 10, 2021
1 parent 62f9397 commit 5988265
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/http_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import (
func HttpGet(url string, header map[string]string, data url.Values) ([]byte, error) {
client := http.Client{Timeout: 10 * time.Second}

req, err := http.NewRequest(http.MethodGet, url+"?"+data.Encode(), nil)
reqUrl := url
if data.Encode() != "" {
reqUrl = url+"?"+data.Encode()
}

req, err := http.NewRequest(http.MethodGet, reqUrl, nil)
for k, v := range header {
req.Header.Add(k, v)
}
Expand Down

0 comments on commit 5988265

Please sign in to comment.