routes: Add handler to generate tar gz file
1 file changed, 14 insertions(+), 0 deletions(-)
changed files
M routes/util.go → routes/util.go
@@ -3,6 +3,7 @@ import ( "io/fs" "log" + "net/http" "os" "path/filepath" "strings"@@ -88,3 +89,16 @@ 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) +}