Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve example for runtime.WithCaptureResponse #21302

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sdk/azcore/runtime/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
// 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 didn't return a response due to an error then *respFromCtx will be nil.
}
Loading