Package callctx provides helpers for storing and retrieving values out of context.Context. These values are used by our client libraries in various ways across the stack.
Index ¶This section is empty.
Functions ¶ func HeadersFromContext ¶HeadersFromContext retrieves headers set from SetHeaders. These headers can then be cast to http.Header or metadata.MD to send along on requests.
func SetHeaders ¶SetHeaders stores key value pairs in the returned context that can later be retrieved by HeadersFromContext. Values stored in this manner will automatically be retrieved by client libraries and sent as outgoing headers on all requests. keyvals should have a corresponding value for every key provided. If there is an odd number of keyvals this method will panic.
Example ¶package main import ( "context" "fmt" "github.com/googleapis/gax-go/v2/callctx" ) func main() { ctx := context.Background() ctx = callctx.SetHeaders(ctx, "key", "value") // Send the returned context to the request you are making. Later on these // values will be retrieved and set on outgoing requests. headers := callctx.HeadersFromContext(ctx) fmt.Println(headers["key"][0]) }
Output: valueTypes ¶
This section is empty.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5