aboutsummaryrefslogtreecommitdiff
path: root/pkg/ext
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-22 16:30:47 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-06-22 16:30:47 +0200
commite1664fcbc4685906d3dabc66bf947a17bce7efc0 (patch)
treec9ec73616b841e72397fca975e46f691d031e621 /pkg/ext
parent19839337ce0c74b67c5480b71e98d97a112aa104 (diff)
downloadcerrado-e1664fcbc4685906d3dabc66bf947a17bce7efc0.tar.gz
cerrado-e1664fcbc4685906d3dabc66bf947a17bce7efc0.tar.bz2
cerrado-e1664fcbc4685906d3dabc66bf947a17bce7efc0.zip
feat: Add archive capability
Diffstat (limited to 'pkg/ext')
-rw-r--r--pkg/ext/mime.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/ext/mime.go b/pkg/ext/mime.go
index 6da66e3..c42d4de 100644
--- a/pkg/ext/mime.go
+++ b/pkg/ext/mime.go
@@ -5,7 +5,8 @@ import "net/http"
type ContentType = string
const (
- TextHTML ContentType = "text/html"
+ TextHTML ContentType = "text/html"
+ ApplicationGZip ContentType = "application/gzip"
)
func Html(next func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
@@ -14,9 +15,17 @@ func Html(next func(w http.ResponseWriter, r *http.Request)) func(w http.Respons
}
}
+func SetFileName(w http.ResponseWriter, name string) {
+ h := "inline; filename=\"" + name + "\""
+ w.Header().Add("Content-Disposition", h)
+}
+
func SetHTML(w http.ResponseWriter) {
SetMIME(w, TextHTML)
+}
+func SetGZip(w http.ResponseWriter) {
+ SetMIME(w, ApplicationGZip)
}
func SetMIME(w http.ResponseWriter, mime ContentType) {