|
@@ -42,6 +42,8 @@ type CdnService interface {
|
|
EditSSLPolicy(ctx context.Context, req v1.SSLPolicy) error
|
|
EditSSLPolicy(ctx context.Context, req v1.SSLPolicy) error
|
|
// 修改反向代理
|
|
// 修改反向代理
|
|
EditProxy(ctx context.Context, req v1.Proxy) error
|
|
EditProxy(ctx context.Context, req v1.Proxy) error
|
|
|
|
+ // 修改日志
|
|
|
|
+ EditWebLog(ctx context.Context,webId int64, req v1.WebLog) error
|
|
}
|
|
}
|
|
|
|
|
|
func NewCdnService(
|
|
func NewCdnService(
|
|
@@ -795,4 +797,29 @@ func (s *cdnService) EditProxy(ctx context.Context, req v1.Proxy) error {
|
|
return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 修改网站日志配置
|
|
|
|
+func (s *cdnService) EditWebLog(ctx context.Context,webId int64, req v1.WebLog) error {
|
|
|
|
+ reqJson, err := json.Marshal(req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ formData := map[string]interface{}{
|
|
|
|
+ "httpWebId": webId,
|
|
|
|
+ "accessLogJSON": reqJson,
|
|
|
|
+ }
|
|
|
|
+ apiUrl := s.Url + "HTTPWebService/updateHTTPWebAccessLog"
|
|
|
|
+ resBody, err := s.sendDataWithTokenRetry(ctx, formData, apiUrl)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ var res v1.GeneralResponse[any]
|
|
|
|
+ if err := json.Unmarshal(resBody, &res); err != nil {
|
|
|
|
+ return fmt.Errorf("反序列化响应 JSON 失败 (内容: %s): %w", string(resBody), err)
|
|
|
|
+ }
|
|
|
|
+ if res.Code != 200 {
|
|
|
|
+ return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
}
|
|
}
|