fix(transport): fix the problem that the context is not delivered correctly (#1906)

pull/1908/head
包子 3 years ago committed by GitHub
parent 99a0646acb
commit 558ef4ebae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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)
})
}
}

Loading…
Cancel
Save