添加一个设置trace_id的中间件

This commit is contained in:
Yun
2024-04-19 09:16:07 +08:00
parent 4f1a91faad
commit 30687b6be6
3 changed files with 20 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
package loggerx
import (
"context"
uuid "github.com/satori/go.uuid"
)
// 可以被引入的中间件
// 自动设置请求ID
func SetTradeId(ctx context.Context) context.Context {
return context.WithValue(ctx, "trade_id", uuid.NewV4().String())
}