game-crawler/utils/request.go
nite 45f7eff8b1 remove model.GameItem.Download
add model.GameItem.DownloadLinks
2024-12-26 14:26:24 +08:00

24 lines
532 B
Go

package utils
import (
"net/http"
"time"
"github.com/go-resty/resty/v2"
)
var client *resty.Client
func init() {
client = resty.New()
client.SetRetryCount(3).SetRetryWaitTime(3 * time.Second).AddRetryCondition(
func(r *resty.Response, err error) bool {
return err != nil || r.StatusCode() == http.StatusTooManyRequests
},
)
}
func Request() *resty.Request {
return client.R().SetHeader("Accept-Charset", "utf-8").SetHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0")
}