chore: RequestGet 还是 使用 url.Values
This commit is contained in:
parent
27715b7b27
commit
0d4b189d3b
@ -14,6 +14,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// vals := url.Values{}
|
||||
@ -48,12 +49,8 @@ func RequestPostJson(url string, data map[string]any) ([]byte, error) {
|
||||
}
|
||||
|
||||
// 比较完整的 get 实现
|
||||
func RequestGet(url string, data map[string]any, headers map[string]string) ([]byte, error) {
|
||||
bd, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("GET", url, bytes.NewBuffer(bd))
|
||||
func RequestGet(uri string, vals url.Values, headers map[string]string) ([]byte, error) {
|
||||
req, err := http.NewRequest("GET", uri, strings.NewReader(vals.Encode()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user