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

Add WithCaptureHTTPRequest #387

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.11.0 (2024-04-09)
- **Feature:** Add method `WithCaptureHTTPRequest` to package `runtime`, which allows capture of HTTP requests for debugging purposes.

## v0.10.1 (2024-03-20)
- **Improvement:** Update `ConfigureRegion` method to take into account global servers without a region variable

Expand Down
3 changes: 3 additions & 0 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ var (

// ContextHTTPResponse holds the raw HTTP response after the request has completed.
ContextHTTPResponse = contextKey("httpResponse")

// ContextHTTPRequest holds the raw HTTP request.
ContextHTTPRequest = contextKey("httpRequest")
)

// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
Expand Down
6 changes: 6 additions & 0 deletions core/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ import (
func WithCaptureHTTPResponse(parent context.Context, resp **http.Response) context.Context {
return context.WithValue(parent, config.ContextHTTPResponse, resp)
}

// WithCaptureHTTPRequest adds the raw HTTP request retrieval annotation to the parent context.
// After the request has completed, the req parameter will contain the raw HTTP request made to the API.
func WithCaptureHTTPRequest(parent context.Context, req **http.Request) context.Context {
return context.WithValue(parent, config.ContextHTTPRequest, req)
}
Loading