NewCachedHTTPClientWithStatuses is like NewCachedHTTPClient, but it also caches responses with the given status codes, such as 403, which are not cached by default.
(httpClient *http.Client, ttl time.Duration, statuses ...int)
| 193 | // NewCachedHTTPClientWithStatuses is like NewCachedHTTPClient, but it also caches responses with the given status |
| 194 | // codes, such as 403, which are not cached by default. |
| 195 | func NewCachedHTTPClientWithStatuses(httpClient *http.Client, ttl time.Duration, statuses ...int) *http.Client { |
| 196 | newClient := NewCachedHTTPClient(httpClient, ttl) |
| 197 | newClient.Transport = addCacheStatusesHeader(newClient.Transport, statuses...) |
| 198 | return newClient |
| 199 | } |
| 200 | |
| 201 | func addCacheStatusesHeader(rt http.RoundTripper, statuses ...int) http.RoundTripper { |
| 202 | if len(statuses) == 0 { |