Skip to content

Commit

Permalink
Improve example for runtime.WithCaptureResponse (#21302)
Browse files Browse the repository at this point in the history
* Improve example for runtime.WithCaptureResponse

* make linter happy

* fix sentence
  • Loading branch information
jhendrixMSFT authored Aug 1, 2023
1 parent c606534 commit 9b73d1f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sdk/azcore/runtime/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 9b73d1f

Please sign in to comment.