rpc: use HTTP request context as top-level context (#16861)

This commit is contained in:
Ryan Schneider 2018-06-02 06:26:47 -04:00 committed by Felix Lange
parent af28d12847
commit c8dcb9584e

View File

@ -181,7 +181,7 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// All checks passed, create a codec that reads direct from the request body // All checks passed, create a codec that reads direct from the request body
// untilEOF and writes the response to w and order the server to process a // untilEOF and writes the response to w and order the server to process a
// single request. // single request.
ctx := context.Background() ctx := r.Context()
ctx = context.WithValue(ctx, "remote", r.RemoteAddr) ctx = context.WithValue(ctx, "remote", r.RemoteAddr)
ctx = context.WithValue(ctx, "scheme", r.Proto) ctx = context.WithValue(ctx, "scheme", r.Proto)
ctx = context.WithValue(ctx, "local", r.Host) ctx = context.WithValue(ctx, "local", r.Host)