optimize code

This commit is contained in:
xing 2025-03-24 09:29:19 +08:00
parent 87d9078625
commit 5dbf67f2f9

View File

@ -37,6 +37,9 @@ 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) { func Get(u string, q map[string]any, a ...any) (res *http.Response, err error) {
cli, req, err := BuildClient(u, "get", q, a...) cli, req, err := BuildClient(u, "get", q, a...)
if err != nil {
return
}
res, err = cli.Do(req) res, err = cli.Do(req)
return return
} }
@ -109,6 +112,9 @@ func BuildClient(u, method string, q map[string]any, a ...any) (res *http.Client
// types 1 x-www-form-urlencoded, 2 form-data, 3 json, 4 binary // types 1 x-www-form-urlencoded, 2 form-data, 3 json, 4 binary
func Post(u string, types int, form map[string]any, a ...any) (res *http.Response, err error) { func Post(u string, types int, form map[string]any, a ...any) (res *http.Response, err error) {
cli, req, err := PostClient(u, types, form, a...) cli, req, err := PostClient(u, types, form, a...)
if err != nil {
return
}
res, err = cli.Do(req) res, err = cli.Do(req)
return return
} }