package ext import "net/http" type ContentType = string const ( 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) { return func(w http.ResponseWriter, r *http.Request) { next(w, r) } } 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) { w.Header().Add("Content-Type", mime) }