(rt http.RoundTripper, statuses ...int)
| 199 | } |
| 200 | |
| 201 | func addCacheStatusesHeader(rt http.RoundTripper, statuses ...int) http.RoundTripper { |
| 202 | if len(statuses) == 0 { |
| 203 | return rt |
| 204 | } |
| 205 | values := make([]string, len(statuses)) |
| 206 | for i, status := range statuses { |
| 207 | values[i] = strconv.Itoa(status) |
| 208 | } |
| 209 | value := strings.Join(values, ",") |
| 210 | return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) { |
| 211 | // If the header is already set in the request, don't overwrite it. |
| 212 | if req.Header.Get(cacheStatuses) == "" { |
| 213 | req.Header.Set(cacheStatuses, value) |
| 214 | } |
| 215 | return rt.RoundTrip(req) |
| 216 | }} |
| 217 | } |
| 218 | |
| 219 | // AddCacheTTLHeader adds a header to the request telling the cache that the request |
| 220 | // should be cached for a specified amount of time. |
no test coverage detected