diff options
Diffstat (limited to 'pkg/ext')
| -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) { | 
