diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-22 16:30:47 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-22 16:30:47 +0200 |
commit | e1664fcbc4685906d3dabc66bf947a17bce7efc0 (patch) | |
tree | c9ec73616b841e72397fca975e46f691d031e621 /pkg/ext/mime.go | |
parent | 19839337ce0c74b67c5480b71e98d97a112aa104 (diff) | |
download | cerrado-e1664fcbc4685906d3dabc66bf947a17bce7efc0.tar.gz cerrado-e1664fcbc4685906d3dabc66bf947a17bce7efc0.tar.bz2 cerrado-e1664fcbc4685906d3dabc66bf947a17bce7efc0.zip |
feat: Add archive capability
Diffstat (limited to 'pkg/ext/mime.go')
-rw-r--r-- | pkg/ext/mime.go | 11 |
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) { |