feat: 改为复用 http client

This commit is contained in:
Mmx233
2022-06-24 20:45:34 +08:00
parent d084f7fdf9
commit 4f99a1da23
9 changed files with 506 additions and 95 deletions

View File

@@ -11,8 +11,8 @@ import (
)
type SrunApi struct {
BaseUrl string
Transport *http.Transport
BaseUrl string
Client *http.Client
}
func (a *SrunApi) request(path string, query map[string]interface{}) (map[string]interface{}, error) {
@@ -24,11 +24,9 @@ func (a *SrunApi) request(path string, query map[string]interface{}) (map[string
}
query["callback"] = callback
query["_"] = timestamp
_, res, e := tool.HTTP.GetString(&tool.GetRequest{
Url: a.BaseUrl + path,
Query: query,
Redirect: true,
Transport: a.Transport,
_, res, e := tool.NewHttpTool(a.Client).GetString(&tool.DoHttpReq{
Url: a.BaseUrl + path,
Query: query,
})
if e != nil {
util.Log.Debug(e)