From acac8d47d0dd4bab02274f750d22937044bee988 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sun, 23 Jun 2024 15:20:47 +0200 Subject: routes: Add handler to generate tar gz file --- routes/util.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'routes/util.go') diff --git a/routes/util.go b/routes/util.go index bc15b7e..1b31b17 100644 --- a/routes/util.go +++ b/routes/util.go @@ -3,6 +3,7 @@ package routes import ( "io/fs" "log" + "net/http" "os" "path/filepath" "strings" @@ -88,3 +89,16 @@ func (d *deps) getAllRepos() ([]repoInfo, error) { func (d *deps) category(path string) string { return strings.TrimPrefix(filepath.Dir(strings.TrimPrefix(path, d.c.Repo.ScanPath)), string(os.PathSeparator)) } + +func setContentDisposition(w http.ResponseWriter, name string) { + h := "inline; filename=\"" + name + "\"" + w.Header().Add("Content-Disposition", h) +} + +func setGZipMIME(w http.ResponseWriter) { + setMIME(w, "application/gzip") +} + +func setMIME(w http.ResponseWriter, mime string) { + w.Header().Add("Content-Type", mime) +} -- cgit v1.2.3