feat: add user-agent http header for thirdparty sdks

This commit is contained in:
Fu Diwei
2025-05-28 10:46:02 +08:00
parent ddb46f9dda
commit 829fa29cf1
30 changed files with 66 additions and 43 deletions

View File

@@ -14,8 +14,6 @@ import (
)
type Client struct {
apiKey string
client *resty.Client
}
@@ -25,7 +23,8 @@ func NewClient(serverUrl, apiVersion, apiKey string) *Client {
}
client := resty.New().
SetBaseURL(strings.TrimRight(serverUrl, "/") + "/api/" + apiVersion).
SetBaseURL(strings.TrimRight(serverUrl, "/")+"/api/"+apiVersion).
SetHeader("User-Agent", "certimate").
SetPreRequestHook(func(c *resty.Client, req *http.Request) error {
timestamp := fmt.Sprintf("%d", time.Now().Unix())
tokenMd5 := md5.Sum([]byte("1panel" + apiKey + timestamp))