fix: 请求工具PUT、POST的超时时间设为3s
This commit is contained in:
@@ -86,7 +86,9 @@ func Post(url string, data url.Values, headers map[string]string) ([]byte, error
|
||||
|
||||
// PostJSON 发送 POST 请求,并将请求体序列化为 JSON 格式
|
||||
func PostJSON(url string, data any, headers map[string]string) ([]byte, error) {
|
||||
client := &http.Client{}
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second, // 超时时间
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
@@ -177,7 +179,9 @@ func PostUploadFile(url string, params map[string]string, file *os.File) ([]byte
|
||||
|
||||
// PutJSON 发送 PUT 请求,并将请求体序列化为 JSON 格式
|
||||
func PutJSON(url string, data any, headers map[string]string) ([]byte, error) {
|
||||
client := &http.Client{}
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second, // 超时时间
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user