From a58dd0c110e0727f88921a3900ba7b4ac5d98a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=85=E5=AD=90?= <906604588@qq.com> Date: Fri, 1 Apr 2022 10:52:32 +0800 Subject: [PATCH] fix(transport): fix the problem that the context is not delivered correctly (#1906) --- transport/http/server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/transport/http/server.go b/transport/http/server.go index 8002624b9..b6e7534be 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -207,6 +207,7 @@ func (s *Server) filter() mux.MiddlewareFunc { // /path/123 -> /path/{id} pathTemplate, _ = route.GetPathTemplate() } + tr := &Transport{ endpoint: s.endpoint.String(), operation: pathTemplate, @@ -215,8 +216,9 @@ func (s *Server) filter() mux.MiddlewareFunc { request: req, pathTemplate: pathTemplate, } - ctx = transport.NewServerContext(ctx, tr) - next.ServeHTTP(w, req.WithContext(ctx)) + + tr.request = req.WithContext(transport.NewServerContext(ctx, tr)) + next.ServeHTTP(w, tr.request) }) } }