inherit requests context from global - fixes termination

This commit is contained in:
Alexander Baryshnikov 2020-10-09 19:38:18 +08:00
parent 6d3d90b0e2
commit b6fd8e1eb2
1 changed files with 4 additions and 0 deletions

View File

@ -99,6 +99,10 @@ func (cfg Config) Create(global context.Context) (*Server, error) {
}
ctx, cancel := context.WithCancel(global)
router := gin.Default()
router.Use(func(gctx *gin.Context) {
gctx.Request = gctx.Request.WithContext(global)
gctx.Next()
})
cfg.installUI(router, units, workers)
server.Attach(router.Group("/api/"), units, workers)