MCPcopy Create free account
hub / github.com/cli/cli / AddCacheTTLHeader

Function AddCacheTTLHeader

api/http_client.go:194–202  ·  view source on GitHub ↗

AddCacheTTLHeader adds a header to the request telling the cache that the request should be cached for a specified amount of time.

(rt http.RoundTripper, ttl time.Duration)

Source from the content-addressed store, hash-verified

192// AddCacheTTLHeader adds a header to the request telling the cache that the request
193// should be cached for a specified amount of time.
194func AddCacheTTLHeader(rt http.RoundTripper, ttl time.Duration) http.RoundTripper {
195 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
196 // If the header is already set in the request, don't overwrite it.
197 if req.Header.Get(cacheTTL) == "" {
198 req.Header.Set(cacheTTL, ttl.String())
199 }
200 return rt.RoundTrip(req)
201 }}
202}
203
204// AddAuthTokenHeader adds an authentication token header for the host specified by the request, using the primitive
205// token source. It is the backward-compatible entry point retained for external callers of this package; gh's own code

Callers 1

NewCachedHTTPClientFunction · 0.85

Calls 4

GetMethod · 0.65
SetMethod · 0.65
StringMethod · 0.65
RoundTripMethod · 0.45

Tested by

no test coverage detected