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

Function AddCacheTTLHeader

api/http_client.go:143–151  ·  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

141// AddCacheTTLHeader adds a header to the request telling the cache that the request
142// should be cached for a specified amount of time.
143func AddCacheTTLHeader(rt http.RoundTripper, ttl time.Duration) http.RoundTripper {
144 return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
145 // If the header is already set in the request, don't overwrite it.
146 if req.Header.Get(cacheTTL) == "" {
147 req.Header.Set(cacheTTL, ttl.String())
148 }
149 return rt.RoundTrip(req)
150 }}
151}
152
153// AddAuthTokenHeader adds an authentication token header for the host specified by the request.
154func AddAuthTokenHeader(rt http.RoundTripper, cfg config) http.RoundTripper {

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