小店商品列表shujuok

This commit is contained in:
yml2213
2026-08-08 17:40:16 +08:00
parent 22dc50196f
commit 379a9d58d3
12 changed files with 2733 additions and 27 deletions
+19 -1
View File
@@ -8,6 +8,7 @@ import (
"mime"
"mime/multipart"
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
@@ -112,7 +113,7 @@ func (t *Recorder) RecordResponse(label string, req *http.Request, resp *http.Re
Time: time.Now().In(constants.CST).Format("2006-01-02 15:04:05.000"),
Label: label,
Method: req.Method,
URL: req.URL.Redacted(),
URL: redactedURL(req.URL),
Path: req.URL.Path,
Status: status,
Cost: cost,
@@ -128,6 +129,23 @@ func (t *Recorder) RecordResponse(label string, req *http.Request, resp *http.Re
_, _ = t.writer.Write([]byte(formatEntry(e)))
}
// redactedURL 隐藏请求 URL 中的账号、角色与签名参数,避免 trace 落盘敏感信息。
func redactedURL(raw *url.URL) string {
if raw == nil {
return ""
}
copyURL := *raw
query := copyURL.Query()
for key := range query {
switch strings.ToLower(key) {
case "userid", "roleid", "openid", "code", "sig", "token", "sid":
query.Set(key, "<hidden>")
}
}
copyURL.RawQuery = query.Encode()
return copyURL.String()
}
// RequestBody 读取请求体用于追踪。
func (t *Recorder) RequestBody(req *http.Request) []byte {
if t == nil || !t.Enabled || req == nil || req.GetBody == nil {