aboutsummaryrefslogtreecommitdiff
path: root/routes/util.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-23 15:20:47 +0200
committerAnirudh Oppiliappan <x@icyphox.sh>2024-06-29 11:16:38 +0300
commitacac8d47d0dd4bab02274f750d22937044bee988 (patch)
tree439bb87c27e9982a594d66531b08180c567d521b /routes/util.go
parentgit: Add function to generate tar file from repo (diff)
downloadlegitrx-acac8d47d0dd4bab02274f750d22937044bee988.tar.gz
legitrx-acac8d47d0dd4bab02274f750d22937044bee988.tar.zst
legitrx-acac8d47d0dd4bab02274f750d22937044bee988.zip
routes: Add handler to generate tar gz file
Diffstat (limited to '')
-rw-r--r--routes/util.go14
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)
+}