引入 GinWrapperContext, gateway待升级测试
This commit is contained in:
@ -67,7 +67,7 @@ func NewContext(ginContext *gin.Context) *Context {
|
||||
return &Context{
|
||||
Context: ginContext,
|
||||
StartRequestTime: time.Now(),
|
||||
FinishRequestTime: time.Time(int64(0)),
|
||||
FinishRequestTime: time.Unix(0, 0),
|
||||
HandlerAfterResponse: make([]gin.HandlerFunc, 0),
|
||||
customData: make(map[string]any),
|
||||
Hostname: hostname,
|
||||
|
@ -326,3 +326,21 @@ func (wh *wrapperHandle) GetLogicAfterResponse(ctx *gin.Context) *define.LogicAf
|
||||
// 就这么写, key值如果被其他人覆盖成非法值, 此处会直接panic
|
||||
return l.(*define.LogicAfterResponse)
|
||||
}
|
||||
|
||||
// GetGinWrapperContext 获取包装之后context
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:41 2025/3/10
|
||||
func (wh *wrapperHandle) GetGinWrapperContext(ctx *gin.Context) *Context {
|
||||
if nil == ctx {
|
||||
return nil
|
||||
}
|
||||
if val, exist := ctx.Get(define.GinWrapperContextKey); !exist || nil == val {
|
||||
newCtx := NewContext(ctx)
|
||||
newCtx.SetCustom(define.GinWrapperContextKey, newCtx)
|
||||
return newCtx
|
||||
} else {
|
||||
return val.(*Context)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user