// CacheHandler returns a handler that serves HTTP requests // with the contents of the specified cache. func CacheHandler(cache *cdc.DiskCache) http.Handler { handler := &cacheHandler{ DiskCache: cache, host: make(map[string]bool), url: make(map[string][]string), } for _, ustr := range cache.URLs() { u, err := url.Parse(ustr) if err != nil { continue } if len(u.Host) != 0 { if !handler.host[u.Host] { handler.host[u.Host] = true } handler.url[u.Host] = append(handler.url[u.Host], ustr) } } return handler }