From e1664fcbc4685906d3dabc66bf947a17bce7efc0 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 22 Jun 2024 16:30:47 +0200 Subject: feat: Add archive capability --- pkg/ext/mime.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'pkg/ext/mime.go') 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) { -- cgit v1.2.3