插件-云闪付红包,查询增加请求超时

This commit is contained in:
李子铭 2024-08-22 10:53:11 +08:00
parent f79f13626b
commit aba1f541f5
1 changed files with 6 additions and 1 deletions

View File

@ -5,7 +5,9 @@ import (
"fmt"
"gitea.cdlsxd.cn/BaseSystem/plugin/proto"
"github.com/carlmjohnson/requests"
"net/http"
"plugins/union_pay_redpack/internal/po"
"time"
)
// 插件通信信息,若不对应则会报错panic
@ -64,7 +66,10 @@ func (p *UnionPayCpnService) Query(ctx context.Context, request *proto.QueryRequ
}
var response po.QueryResp
url := fmt.Sprintf("%s%s", c.BaseUri, queryMethod)
err = requests.URL(url).Headers(headers(c, uv, queryBizMethod)).BodyJSON(uv).ToJSON(&response).Fetch(ctx)
h := new(http.Client)
h.Timeout = 100 * time.Millisecond
err = requests.URL(url).Client(h).Headers(headers(c, uv, queryBizMethod)).BodyJSON(uv).ToJSON(&response).Fetch(ctx)
if err != nil {
return nil, fmt.Errorf("请求异常msg:" + err.Error())
}