blob: c42d4de563775a21af2511f6b2dc18562f62626a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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)
}
|