diff --git a/gweb/requestid/options.go b/gweb/requestid/options.go index b36b7b1..92afe13 100644 --- a/gweb/requestid/options.go +++ b/gweb/requestid/options.go @@ -7,14 +7,14 @@ package requestid -import "git.hexq.cn/tiglog/golib/gweb" +import "github.com/gin-gonic/gin" // Option for queue system type Option func(*config) type ( Generator func() string - Handler func(c *gweb.Context, requestID string) + Handler func(c *gin.Context, requestID string) ) type HeaderStrKey string diff --git a/gweb/requestid/reqid.go b/gweb/requestid/reqid.go index ab4f336..821aa0e 100644 --- a/gweb/requestid/reqid.go +++ b/gweb/requestid/reqid.go @@ -8,7 +8,7 @@ package requestid import ( - "git.hexq.cn/tiglog/golib/gweb" + "github.com/gin-gonic/gin" "github.com/rs/xid" ) @@ -26,7 +26,7 @@ type config struct { } // New initializes the RequestID middleware. -func New(opts ...Option) gweb.HandlerFunc { +func New(opts ...Option) gin.HandlerFunc { cfg := &config{ generator: func() string { return xid.New().String() @@ -40,7 +40,7 @@ func New(opts ...Option) gweb.HandlerFunc { headerXRequestID = string(cfg.headerKey) - return func(c *gweb.Context) { + return func(c *gin.Context) { // Get id from request rid := c.GetHeader(headerXRequestID) if rid == "" { @@ -57,6 +57,6 @@ func New(opts ...Option) gweb.HandlerFunc { } // Get returns the request identifier -func Get(c *gweb.Context) string { +func Get(c *gin.Context) string { return c.GetHeader(headerXRequestID) } diff --git a/gweb/wrapper.go b/gweb/wrapper.go index 593fe37..f76d182 100644 --- a/gweb/wrapper.go +++ b/gweb/wrapper.go @@ -9,6 +9,7 @@ package gweb import "github.com/gin-gonic/gin" +type GinContext = gin.Context type H = gin.H type HandlersChain = gin.HandlersChain type RouteInfo = gin.RouteInfo