cerrado @ 92c57a05fab452c1de83131498552424c9c5b598

 1package ext
 2
 3import "net/http"
 4
 5type ContentType = string
 6
 7const (
 8	TextHTML        ContentType = "text/html"
 9	ApplicationGZip ContentType = "application/gzip"
10)
11
12func Html(next func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
13	return func(w http.ResponseWriter, r *http.Request) {
14		next(w, r)
15	}
16}
17
18func SetFileName(w http.ResponseWriter, name string) {
19	h := "inline; filename=\"" + name + "\""
20	w.Header().Add("Content-Disposition", h)
21}
22
23func SetHTML(w http.ResponseWriter) {
24	SetMIME(w, TextHTML)
25}
26
27func SetGZip(w http.ResponseWriter) {
28	SetMIME(w, ApplicationGZip)
29}
30
31func SetMIME(w http.ResponseWriter, mime ContentType) {
32	w.Header().Add("Content-Type", mime)
33}