diff options
Diffstat (limited to 'routes/util.go')
-rw-r--r-- | routes/util.go | 14 |
1 files changed, 14 insertions, 0 deletions
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) +} |