1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

get req from ctx (#975)

Co-authored-by: longXboy <longxboy@gmail.com>
This commit is contained in:
longxboy 2021-05-31 22:17:47 +08:00 committed by GitHub
parent f51bd97324
commit 930d1f6cf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,12 +54,13 @@ func Server(opts ...Option) middleware.Middleware {
method = "POST"
path = info.FullMethod
} else if info, ok := http.FromServerContext(ctx); ok {
method = info.Request.Method
if route := mux.CurrentRoute(info.Request); route != nil {
req := info.Request.WithContext(ctx)
method = req.Method
if route := mux.CurrentRoute(req); route != nil {
// /path/123 -> /path/{id}
path, _ = route.GetPathTemplate()
} else {
path = info.Request.RequestURI
path = req.RequestURI
}
}
startTime := time.Now()