Преглед на файлове

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

Ryan Schneider преди 7 години
родител
ревизия
c8dcb9584e
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      rpc/http.go

+ 1 - 1
rpc/http.go

@@ -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
 	// untilEOF and writes the response to w and order the server to process a
 	// single request.
-	ctx := context.Background()
+	ctx := r.Context()
 	ctx = context.WithValue(ctx, "remote", r.RemoteAddr)
 	ctx = context.WithValue(ctx, "scheme", r.Proto)
 	ctx = context.WithValue(ctx, "local", r.Host)