all repos — elgit @ acac8d47d0dd4bab02274f750d22937044bee988

fork of legit: web frontend for git, written in go

routes: Add handler to generate tar gz file

Gabriel A. Giovanini
commit

acac8d47d0dd4bab02274f750d22937044bee988

parent

86b2bf47ff930778bd73cce1cda916ffad41518b

1 file changed, 14 insertions(+), 0 deletions(-)

changed files
M routes/util.goroutes/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) +}