From 5d93eca50ac0f22903b8ff29bba1c9169f17806b Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 11 May 2023 17:42:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96web=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/gin/engine/context.go | 9 +++++---- lego/sys/gin/engine/engine.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lego/sys/gin/engine/context.go b/lego/sys/gin/engine/context.go index bfc21f4be..2c8132fab 100644 --- a/lego/sys/gin/engine/context.go +++ b/lego/sys/gin/engine/context.go @@ -33,6 +33,7 @@ const abortIndex int8 = math.MaxInt8 >> 1 func newContext(log log.ILogger, engine *Engine, params *Params, skippedNodes *[]skippedNode) *Context { return &Context{ + Log: log, engine: engine, params: params, skippedNodes: skippedNodes, @@ -102,8 +103,8 @@ func (this *Context) Handler() HandlerFunc { FullPath 返回匹配的路由完整路径。 对于未找到的路线 返回一个空字符串。 */ -func (c *Context) FullPath() string { - return c.fullPath +func (this *Context) FullPath() string { + return this.fullPath } func (this *Context) Next() { @@ -216,8 +217,8 @@ func (this *Context) GetUint(key string) (ui uint) { return } -func (c *Context) GetUInt32(key string) (i uint32) { - if val, ok := c.Get(key); ok && val != nil { +func (this *Context) GetUInt32(key string) (i uint32) { + if val, ok := this.Get(key); ok && val != nil { i, _ = val.(uint32) } return diff --git a/lego/sys/gin/engine/engine.go b/lego/sys/gin/engine/engine.go index 91a106d3e..ff5135bcc 100644 --- a/lego/sys/gin/engine/engine.go +++ b/lego/sys/gin/engine/engine.go @@ -491,7 +491,7 @@ func (this *Engine) prepareTrustedCIDRs() ([]*net.IPNet, error) { func (this *Engine) allocateContext() *Context { v := make(Params, 0, this.maxParams) skippedNodes := make([]skippedNode, 0, this.maxSections) - return &Context{Log: this.log, engine: this, params: &v, skippedNodes: &skippedNodes} + return newContext(this.log, this, &v, &skippedNodes) //& Context{Log: this.log, engine: this, params: &v, skippedNodes: &skippedNodes} } //日志接口-------------------------------------------------------------