package wx import ( "io" "net/http" "strings" ) const ( post = "POST" get = "GET" ) var client = &http.Client{} // @Title 请求 func request(method, url, data string, headers ...map[string]string) ([]byte, error) { reqest, err := http.NewRequest(method, url, strings.NewReader(data)) if err != nil { return nil, err } if len(headers) > 0 { for key, value := range headers[0] { reqest.Header.Add(key, value) } } response, err := client.Do(reqest) if err != nil { return nil, err } defer response.Body.Close() result, err := io.ReadAll(response.Body) if err != nil { return nil, err } return result, nil }