File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,15 +16,9 @@ import (
1616// contextKeys are used to identify the type of value in the context.
1717// Since these are string, it is possible to get a short description of the
1818// context key for logging and debugging using key.String().
19-
2019type contextKey string
2120
22- func (c contextKey ) String () string {
23- return "auth " + string (c )
24- }
25-
2621var (
27-
2822 // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
2923 ContextOAuth2 = contextKey ("token" )
3024
5145
5246 // ContextOperationServerVariables overrides a server configuration variables using operation specific values.
5347 ContextOperationServerVariables = contextKey ("serverOperationVariables" )
48+
49+ // ContextHTTPResponse holds the raw HTTP response after the request has completed.
50+ ContextHTTPResponse = contextKey ("httpResponse" )
5451)
5552
5653// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
@@ -311,6 +308,12 @@ func WithCustomConfiguration(cfg *Configuration) ConfigurationOption {
311308 }
312309}
313310
311+ // WithCaptureHTTPResponse adds the raw HTTP response retrieval annotation to the parent context.
312+ // The resp parameter will contain the raw HTTP response after the request has completed.
313+ func WithCaptureHTTPResponse (parent context.Context , resp * * http.Response ) context.Context {
314+ return context .WithValue (parent , ContextHTTPResponse , resp )
315+ }
316+
314317// ServerVariable stores the information about a server variable
315318type ServerVariable struct {
316319 Description string
You can’t perform that action at this time.
0 commit comments