Skip to content

Commit 687118a

Browse files
authored
Add WithCaptureHTTPRequest (#387)
* add WithCaptureHTTPRequest, prep for template change
1 parent c43c8a8 commit 687118a

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

core/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.11.0 (2024-04-09)
2+
- **Feature:** Add method `WithCaptureHTTPRequest` to package `runtime`, which allows capture of HTTP requests for debugging purposes.
3+
14
## v0.10.1 (2024-03-20)
25
- **Improvement:** Update `ConfigureRegion` method to take into account global servers without a region variable
36

core/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ var (
5252

5353
// ContextHTTPResponse holds the raw HTTP response after the request has completed.
5454
ContextHTTPResponse = contextKey("httpResponse")
55+
56+
// ContextHTTPRequest holds the raw HTTP request.
57+
ContextHTTPRequest = contextKey("httpRequest")
5558
)
5659

5760
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

core/runtime/runtime.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ import (
1212
func WithCaptureHTTPResponse(parent context.Context, resp **http.Response) context.Context {
1313
return context.WithValue(parent, config.ContextHTTPResponse, resp)
1414
}
15+
16+
// WithCaptureHTTPRequest adds the raw HTTP request retrieval annotation to the parent context.
17+
// After the request has completed, the req parameter will contain the raw HTTP request made to the API.
18+
func WithCaptureHTTPRequest(parent context.Context, req **http.Request) context.Context {
19+
return context.WithValue(parent, config.ContextHTTPRequest, req)
20+
}

0 commit comments

Comments
 (0)