req
req copied to clipboard
SetProxyURL 后是否可以自主清除Proxy
var repsClient = req.C().
SetBaseURL("https://sc.scm121.com/api").SetCommonContentType("application/json; charset=utf-8").
SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36").
SetTimeout(1 * time.Minute).EnableDumpAllToFile("./runtime/dumpReq.txt")
func (c Content) RequestGet(url string, urlParams map[string]string) (JSON, error) {
var (
result reqsResult
repsClientNew = repsClient
)
if c.Proxy != "" {
repsClientNew = repsClientNew.SetProxyURL(c.Proxy)
}
res, _ := repsClientNew.R().SetQueryParams(urlParams).SetSuccessResult(&result).Get(url)
return JSON(nil), res.Err
}
我写了一个通用的Request Get 只要被代理访问了,有些地方不需要代理访问也会经过代理, 我repsClientNew 设置的代理 repsClient没有从没设置过代理 , repsClientNew 代理怎么 会跑给 repsClient 导致所有 repsClient 都设置了这个代理。