Skip to content

Commit 9b73d1f

Browse files
authored
Improve example for runtime.WithCaptureResponse (#21302)
* Improve example for runtime.WithCaptureResponse * make linter happy * fix sentence
1 parent c606534 commit 9b73d1f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sdk/azcore/runtime/examples_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44
// Copyright (c) Microsoft Corporation. All rights reserved.
55
// Licensed under the MIT License.
66

7-
package runtime
7+
package runtime_test
88

99
import (
1010
"context"
1111
"net/http"
12+
13+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
1214
)
1315

1416
func ExampleWithCaptureResponse() {
1517
var respFromCtx *http.Response
16-
WithCaptureResponse(context.Background(), &respFromCtx)
18+
ctx := context.TODO()
19+
ctx = runtime.WithCaptureResponse(ctx, &respFromCtx)
20+
// make some client method call using the updated context
21+
// resp, err := client.SomeMethod(ctx, ...)
22+
// *respFromCtx contains the raw *http.Response returned during the client method call.
23+
// if the HTTP transport didn't return a response due to an error then *respFromCtx will be nil.
24+
_ = ctx
1725
}

0 commit comments

Comments
 (0)