-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.go
99 lines (89 loc) · 2.04 KB
/
variables.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"encoding/json"
"encoding/xml"
"io"
"net/http"
"net/url"
"reflect"
)
var (
JSONDecoder = func(reader io.Reader) func(v interface{}) error {
return json.NewDecoder(reader).Decode
}
JSONEncoder = func(writer io.Writer) func(v interface{}) error {
return json.NewEncoder(writer).Encode
}
XMLDecoder = func(reader io.Reader) func(v interface{}) error {
return xml.NewDecoder(reader).Decode
}
XMLEncoder = func(writer io.Writer) func(v interface{}) error {
return xml.NewEncoder(writer).Encode
}
DefaultErrorMapper ErrorMapper = func(err error, w http.ResponseWriter, r *http.Request) error {
http.Error(w, err.Error(), http.StatusInternalServerError)
return nil
}
Application = struct {
JSON ContentType
XML ContentType
ZIP ContentType
GZIP ContentType
PDF ContentType
}{
JSON: func() string {
return "application/json; charset=utf-8"
},
XML: func() string {
return "application/xml; charset=utf-8"
},
ZIP: func() string {
return "application/zip"
},
GZIP: func() string {
return "application/gzip"
},
PDF: func() string {
return "application/pdf; charset=utf-8"
},
}
Multipart = struct {
FormData ContentType
}{
FormData: func() string {
return "multipart/form-data; charset=utf-8"
},
}
Text = struct {
CMD ContentType
CSS ContentType
CSV ContentType
HTML ContentType
Plain ContentType
XML ContentType
}{
CMD: func() string {
return "text/cmd; charset=utf-8"
},
CSS: func() string {
return "text/css; charset=utf-8"
},
CSV: func() string {
return "text/csv; charset=utf-8"
},
HTML: func() string {
return "text/html; charset=utf-8"
},
Plain: func() string {
return "text/plain; charset=utf-8"
},
XML: func() string {
return "text/xml; charset=utf-8"
},
}
headersType = reflect.TypeOf(http.Header{})
urlQueryType = reflect.TypeOf(url.Values{})
cookiesType = reflect.TypeOf([]*http.Cookie{})
errorType = reflect.TypeOf((*error)(nil)).Elem()
httpStatusType = reflect.TypeOf(http.StatusOK)
)