We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
配置文件热更新后,对于某些已使用的地方是无效的 main.go
// 对于以下变量即使global.ServerSetting发生变化也是不会更新的 gin.SetMode(global.ServerSetting.RunMode) router := routers.NewRouter() s := &http.Server{ Addr: ":" + global.ServerSetting.HttpPort, Handler: router, ReadTimeout: global.ServerSetting.ReadTimeout, WriteTimeout: global.ServerSetting.WriteTimeout, MaxHeaderBytes: 1 << 20, } ...
router.go
... // 因为超时中间件参数是值传递,所以即使global.AppSetting.DefaultContextTimeout发生改变,该中间件还是只会使用首次注册时的参数值 r.Use(middleware.ContextTimeout(global.AppSetting.DefaultContextTimeout))
解决: 修改context_timeout.go ContextTimeout的值传递改为引用传递
func ContextTimeout(d *time.Duration) gin.HandlerFunc { return func(c *gin.Context) { ctx, cancel := context.WithTimeout(c.Request.Context(), *d) defer cancel() c.Request = c.Request.WithContext(ctx) c.Next() } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
配置文件热更新后,对于某些已使用的地方是无效的
main.go
router.go
解决:
修改context_timeout.go
ContextTimeout的值传递改为引用传递
The text was updated successfully, but these errors were encountered: