in util/testutil/http.go [23:47]
func (z *ZipDirHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
archiveName := path.Base(req.URL.Path) + ".zip"
zip := archiver.NewZip()
defer func() {
zip.Close()
if err := os.Remove(archiveName); err != nil {
log.Println(err, "removing", req.URL.Path)
return
}
log.Printf("zipped request %s", req.URL.Path)
}()
zip.Archive([]string{filepath.Join(z.Root, req.URL.Path)}, archiveName)
b, err := ioutil.ReadFile(archiveName)
if err != nil {
w.WriteHeader(500)
return
}
w.Header().Set("Content-Disposition", "attachment; filename="+archiveName+".zip")
w.Header().Set("Content-Type", "application/zip")
w.Write(b)
}