优化支付日志和配置删除提示

This commit is contained in:
yml
2026-06-18 22:16:09 +08:00
parent fa14e0e36d
commit 9b06673efb
15 changed files with 381 additions and 92 deletions
+25
View File
@@ -0,0 +1,25 @@
package logging
import "context"
type requestIDContextKey struct{}
// WithRequestID 把请求 ID 写入标准 context,供非 HTTP 层日志关联请求链路。
func WithRequestID(ctx context.Context, requestID string) context.Context {
if ctx == nil || requestID == "" {
return ctx
}
return context.WithValue(ctx, requestIDContextKey{}, requestID)
}
// RequestIDFromContext 从标准 context 读取请求 ID。
func RequestIDFromContext(ctx context.Context) string {
if ctx == nil {
return ""
}
value, ok := ctx.Value(requestIDContextKey{}).(string)
if !ok {
return ""
}
return value
}