From e9c2aa60d0203e6c799b34de0dd63871e298ca8a Mon Sep 17 00:00:00 2001
From: dtapps
Date: Wed, 27 Mar 2024 10:54:09 +0800
Subject: [PATCH] - update
---
README.md | 2 +-
const.go | 1 +
context.go | 7 ++++++-
version.go | 2 +-
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 566158d..13c28bc 100644
--- a/README.md
+++ b/README.md
@@ -13,5 +13,5 @@
#### 安装
```shell
-go get -v -u go.dtapp.net/gotrace_id@v1.0.11
+go get -v -u go.dtapp.net/gotrace_id@v1.0.12
```
diff --git a/const.go b/const.go
index 517d182..3b097f6 100644
--- a/const.go
+++ b/const.go
@@ -6,4 +6,5 @@ const (
TraceIdKey = "trace_id"
TraceIdGinKey = "trace_id"
TraceIdRequestKey = "X-Request-Id"
+ TraceIDRequestKey = "X-Request-ID"
)
diff --git a/context.go b/context.go
index 629277c..b2df7d4 100644
--- a/context.go
+++ b/context.go
@@ -26,7 +26,12 @@ func SetGinTraceIdContext(ctx context.Context, c *gin.Context) context.Context {
// GetTraceIdContext 通过上下文获取跟踪编号
func GetTraceIdContext(ctx context.Context) string {
- traceId := fmt.Sprintf("%s", ctx.Value(TraceIdKey))
+ return CustomGetTraceIdContext(ctx, TraceIdKey)
+}
+
+// CustomGetTraceIdContext 通过自定义上下文获取跟踪编号
+func CustomGetTraceIdContext(ctx context.Context, key string) string {
+ traceId := fmt.Sprintf("%s", ctx.Value(key))
if traceId == Nil {
return ""
}
diff --git a/version.go b/version.go
index 177fa63..4b9aa09 100644
--- a/version.go
+++ b/version.go
@@ -1,3 +1,3 @@
package gotrace_id
-const Version = "1.0.11"
+const Version = "1.0.12"