fix: 修复一些错误引用
This commit is contained in:
		@ -11,11 +11,11 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/trace"
 | 
						"git.zhangdeman.cn/zhangdeman/consts"
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/wrapper/op_ternary"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/gin/define"
 | 
						"git.zhangdeman.cn/zhangdeman/gin/define"
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/gin/request/parse_body"
 | 
						"git.zhangdeman.cn/zhangdeman/gin/request/parse_body"
 | 
				
			||||||
 | 
						"git.zhangdeman.cn/zhangdeman/trace"
 | 
				
			||||||
 | 
						"git.zhangdeman.cn/zhangdeman/wrapper/op_ternary"
 | 
				
			||||||
	"github.com/gin-gonic/gin"
 | 
						"github.com/gin-gonic/gin"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -242,33 +242,29 @@ func (wh *wrapperHandle) ParseCookie(ctx *gin.Context) map[string]string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetLogicAfterResponse ...
 | 
					// GetLogicAfterResponse ...
 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Author : go_developer@163.com<白茶清欢>
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Date : 16:54 2025/2/28
 | 
					 | 
				
			||||||
func (wh *wrapperHandle) GetLogicAfterResponse(ctx *gin.Context) *define.LogicAfterResponse {
 | 
					func (wh *wrapperHandle) GetLogicAfterResponse(ctx *gin.Context) *define.LogicAfterResponse {
 | 
				
			||||||
	if nil == ctx || nil == ctx.Request {
 | 
						if nil == ctx || nil == ctx.Request {
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	l, exist := ctx.Get(define.LogicAfterResponseKey)
 | 
						l, exist := ctx.Get(consts.GinLogicAfterResponseKey)
 | 
				
			||||||
	if !exist || nil == l {
 | 
						if !exist || nil == l {
 | 
				
			||||||
		l = &define.LogicAfterResponse{
 | 
							l = &define.LogicAfterResponse{
 | 
				
			||||||
			SuccessHookFuncList: make([]func(), 0),
 | 
								SuccessHookFuncList: make([]func(ctx *gin.Context), 0),
 | 
				
			||||||
			FailureHookFuncList: make([]func(), 0),
 | 
								FailureHookFuncList: make([]func(ctx *gin.Context), 0),
 | 
				
			||||||
			Lock:                &sync.RWMutex{},
 | 
								Lock:                &sync.RWMutex{},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ctx.Set(define.LogicAfterResponseKey, l)
 | 
							ctx.Set(consts.GinLogicAfterResponseKey, l)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// 就这么写, key值如果被其他人覆盖成非法值, 此处会直接panic
 | 
						// 就这么写, key值如果被其他人覆盖成非法值, 此处会直接panic
 | 
				
			||||||
	return l.(*define.LogicAfterResponse)
 | 
						return l.(*define.LogicAfterResponse)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetCustomContext 获取自定义context
 | 
					 | 
				
			||||||
func (wh *wrapperHandle) GetCustomContext(ctx *gin.Context) *define.Context {
 | 
					 | 
				
			||||||
	return define.NewContext(ctx)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// GetTraceInstance 获取trace实例
 | 
					// GetTraceInstance 获取trace实例
 | 
				
			||||||
func (wh *wrapperHandle) GetTraceInstance(ctx *gin.Context) *trace.Runtime {
 | 
					func (wh *wrapperHandle) GetTraceInstance(ctx *gin.Context) *trace.Runtime {
 | 
				
			||||||
	return define.NewContext(ctx).Trace
 | 
						i, exist := ctx.Get(consts.GinTraceInstanceField)
 | 
				
			||||||
 | 
						if !exist || nil == i {
 | 
				
			||||||
 | 
							i = trace.NewRuntime(wh.GetCtxStringData(ctx, consts.GinTraceIDField, ""), 2)
 | 
				
			||||||
 | 
							ctx.Set(consts.GinTraceInstanceField, i)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return i.(*trace.Runtime)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -82,8 +82,8 @@ func (s *server) RequestHandler(uriCfg UriConfig) gin.HandlerFunc {
 | 
				
			|||||||
		ctx.Set(consts.GinRequestSuccess, false)
 | 
							ctx.Set(consts.GinRequestSuccess, false)
 | 
				
			||||||
		// 初始化响应之后logic
 | 
							// 初始化响应之后logic
 | 
				
			||||||
		logicAfterResponse := &define.LogicAfterResponse{
 | 
							logicAfterResponse := &define.LogicAfterResponse{
 | 
				
			||||||
			SuccessHookFuncList: make([]func(), 0),
 | 
								SuccessHookFuncList: make([]func(ctx *gin.Context), 0),
 | 
				
			||||||
			FailureHookFuncList: make([]func(), 0),
 | 
								FailureHookFuncList: make([]func(ctx *gin.Context), 0),
 | 
				
			||||||
			Lock:                &sync.RWMutex{},
 | 
								Lock:                &sync.RWMutex{},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// 此处暴露出去,是为了使用方可以获取到对应数据
 | 
							// 此处暴露出去,是为了使用方可以获取到对应数据
 | 
				
			||||||
 | 
				
			|||||||
@ -15,8 +15,6 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/graceful"
 | 
						"git.zhangdeman.cn/zhangdeman/graceful"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/gin/define"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	apiDoc "git.zhangdeman.cn/zhangdeman/api-doc"
 | 
						apiDoc "git.zhangdeman.cn/zhangdeman/api-doc"
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/consts"
 | 
						"git.zhangdeman.cn/zhangdeman/consts"
 | 
				
			||||||
	"git.zhangdeman.cn/zhangdeman/gin/middleware"
 | 
						"git.zhangdeman.cn/zhangdeman/gin/middleware"
 | 
				
			||||||
@ -67,10 +65,6 @@ func newServerOption(port int, optionList ...SetServerOptionFunc) *serverOption
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewServer server实例
 | 
					// NewServer server实例
 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Author : go_developer@163.com<白茶清欢>
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Date : 18:20 2025/2/7
 | 
					 | 
				
			||||||
func NewServer(port int, optionList ...SetServerOptionFunc) *server {
 | 
					func NewServer(port int, optionList ...SetServerOptionFunc) *server {
 | 
				
			||||||
	if port < 80 {
 | 
						if port < 80 {
 | 
				
			||||||
		panic("port should be greater than 80")
 | 
							panic("port should be greater than 80")
 | 
				
			||||||
@ -86,10 +80,6 @@ func NewServer(port int, optionList ...SetServerOptionFunc) *server {
 | 
				
			|||||||
	// CustomContext 必须在第一个, 并且进行初始化
 | 
						// CustomContext 必须在第一个, 并且进行初始化
 | 
				
			||||||
	globalMiddlewareList = append(
 | 
						globalMiddlewareList = append(
 | 
				
			||||||
		globalMiddlewareList,
 | 
							globalMiddlewareList,
 | 
				
			||||||
		func(ctx *gin.Context) {
 | 
					 | 
				
			||||||
			// 初始化上下文以及基础信息
 | 
					 | 
				
			||||||
			_ = define.NewContext(ctx)
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	if nil != option.loggerCfg {
 | 
						if nil != option.loggerCfg {
 | 
				
			||||||
		// 请求日志记录中间件
 | 
							// 请求日志记录中间件
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user