From 9b73d1f0bc301cb2f9827ae16b9c1d4d66b46756 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Tue, 1 Aug 2023 16:02:10 -0700 Subject: [PATCH] Improve example for runtime.WithCaptureResponse (#21302) * Improve example for runtime.WithCaptureResponse * make linter happy * fix sentence --- sdk/azcore/runtime/examples_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/azcore/runtime/examples_test.go b/sdk/azcore/runtime/examples_test.go index 0294baedda39..425e9e3fbbdf 100644 --- a/sdk/azcore/runtime/examples_test.go +++ b/sdk/azcore/runtime/examples_test.go @@ -4,14 +4,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package runtime +package runtime_test import ( "context" "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" ) func ExampleWithCaptureResponse() { var respFromCtx *http.Response - WithCaptureResponse(context.Background(), &respFromCtx) + ctx := context.TODO() + ctx = runtime.WithCaptureResponse(ctx, &respFromCtx) + // make some client method call using the updated context + // resp, err := client.SomeMethod(ctx, ...) + // *respFromCtx contains the raw *http.Response returned during the client method call. + // if the HTTP transport didn't return a response due to an error then *respFromCtx will be nil. + _ = ctx }