feat: enhance environment configuration and resource initialization

This commit is contained in:
CaIon
2025-07-01 13:13:30 +08:00
parent 6b9237f868
commit eb265a55e1
9 changed files with 90 additions and 64 deletions

View File

@@ -13,9 +13,8 @@ import (
)
var httpClient *http.Client
var impatientHTTPClient *http.Client
func init() {
func InitHttpClient() {
if common.RelayTimeout == 0 {
httpClient = &http.Client{}
} else {
@@ -23,20 +22,12 @@ func init() {
Timeout: time.Duration(common.RelayTimeout) * time.Second,
}
}
impatientHTTPClient = &http.Client{
Timeout: 5 * time.Second,
}
}
func GetHttpClient() *http.Client {
return httpClient
}
func GetImpatientHttpClient() *http.Client {
return impatientHTTPClient
}
// NewProxyHttpClient 创建支持代理的 HTTP 客户端
func NewProxyHttpClient(proxyURL string) (*http.Client, error) {
if proxyURL == "" {

View File

@@ -101,7 +101,7 @@ func SendWebhookNotify(webhookURL string, secret string, data dto.Notify) error
}
// 发送请求
client := GetImpatientHttpClient()
client := GetHttpClient()
resp, err = client.Do(req)
if err != nil {
return fmt.Errorf("failed to send webhook request: %v", err)