优化http连接池

This commit is contained in:
2025-08-03 14:20:17 +08:00
parent 838430ee2f
commit 84ccaa56de
4 changed files with 45 additions and 13 deletions

View File

@@ -9,7 +9,6 @@ import (
"io"
"log"
"net/http"
"time"
)
func SyncTask() ([]dto.Task, error) {
@@ -29,10 +28,7 @@ func SyncTask() ([]dto.Task, error) {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{
Timeout: 5 * time.Second, // 设置超时时间为5秒
}
resp, err := client.Do(req)
resp, err := GetAPIClient().Do(req)
if err != nil {
log.Println("Error sending request:", err)
return nil, err