forked from eaciit/knot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
responseconfig.go
54 lines (46 loc) · 1001 Bytes
/
responseconfig.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
package knot
import (
"net/http"
)
type OutputType int
const (
OutputTemplate OutputType = 0
OutputHtml OutputType = 10
OutputJson OutputType = 100
OutputByte OutputType = 1000
)
func (o OutputType) String() string {
if o == OutputTemplate {
return "Template"
} else if o == OutputHtml {
return "HTML"
} else if o == OutputJson {
return "JSON"
} else if o == OutputByte {
return "Byte"
}
return "N/A"
}
type ResponseConfig struct {
AppName string
ViewName string
OutputType OutputType
LayoutTemplate string
ViewsPath string
IncludeFiles []string
Headers map[string]string
cookies map[string]*http.Cookie
}
func NewResponseConfig() *ResponseConfig {
c := new(ResponseConfig)
c.Headers = map[string]string{}
c.IncludeFiles = []string{}
c.OutputType = DefaultOutputType
return c
}
func (r *ResponseConfig) Cookies() map[string]*http.Cookie {
if r.cookies == nil {
r.cookies = map[string]*http.Cookie{}
}
return r.cookies
}