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