From d220bb2a6cbe57e35246846122accff8563f44ea Mon Sep 17 00:00:00 2001 From: xing Date: Wed, 12 Jun 2024 17:51:47 +0800 Subject: [PATCH] optimize code --- helper/httptool/http.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helper/httptool/http.go b/helper/httptool/http.go index 6415070..5ac13b6 100644 --- a/helper/httptool/http.go +++ b/helper/httptool/http.go @@ -36,7 +36,7 @@ func GetString(u string, q map[string]any, a ...any) (r string, code int, err er } func Get(u string, q map[string]any, a ...any) (res *http.Response, err error) { - cli, req, err := GetClient(u, q, a...) + cli, req, err := BuildClient(u, "get", q, a...) res, err = cli.Do(req) return } @@ -85,7 +85,7 @@ func PostFormDataString(u string, form map[string]any, a ...any) (r string, code return } -func GetClient(u string, q map[string]any, a ...any) (res *http.Client, req *http.Request, err error) { +func BuildClient(u, method string, q map[string]any, a ...any) (res *http.Client, req *http.Request, err error) { parse, err := url.Parse(u) if err != nil { return nil, nil, err @@ -95,7 +95,7 @@ func GetClient(u string, q map[string]any, a ...any) (res *http.Client, req *htt setValue(q, values) parse.RawQuery = values.Encode() req = &http.Request{ - Method: "GET", + Method: strings.ToUpper(method), URL: parse, } SetArgs(&cli, req, a...)