Closed xuzq3 closed 4 years ago
Which library has a bug? go2sky or 3rd party?
Which library has a bug? go2sky or 3rd party?
go2sky/plugins/gin/gin.go
Could you try to submit a pull request to fix it?
Hi @xuzq3 can you provide your code, I can't reproduce this bug :)
go2sky/plugins/gin/gin.go
m.routeMapOnce.Do(func() {
routes := engine.Routes()
rm := make(map[string]map[string]routeInfo)
for _, r := range routes {
mm := rm[r.Method]
if mm == nil {
mm = make(map[string]routeInfo)
rm[r.Method] = mm
}
mm[r.Handler] = routeInfo{
operationName: c.Request.Host + c.Request.URL.Path,same
}
m.routeMap = rm
}
})
Because of sync.Once, routeMap is initialized by gin.Context of the first request. And it will never change. When the url of the next request is different, operationName is wrong.
haha @xuzq3 are you interested in fixing it :)
gin.Middleware has a bug to initialize routeMap by gin.Context and the operationName will be wrong for the next request.