-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
51 lines (44 loc) · 1.04 KB
/
config.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
package nrfiber
const (
configKeyNoticeErrorEnabled = "NoticeErrorEnabled"
configKeyStatusCodeIgnored = "StatusCodeIgnored"
)
type config struct {
key string
value interface{}
}
func ConfigNoticeErrorEnabled(enabled bool) *config {
return &config{
key: configKeyNoticeErrorEnabled,
value: enabled,
}
}
func ConfigStatusCodeIgnored(statusCode []int) *config {
return &config{
key: configKeyStatusCodeIgnored,
value: statusCode,
}
}
func createConfigMap(configs ...*config) map[string]interface{} {
configMap := make(map[string]interface{}, len(configs))
for _, c := range configs {
configMap[c.key] = c.value
}
return configMap
}
func noticeErrorEnabled(configMap map[string]interface{}) bool {
if val, ok := configMap[configKeyNoticeErrorEnabled]; ok {
if boolVal, ok := val.(bool); ok {
return boolVal
}
}
return false
}
func statusCodeIgnored(configMap map[string]interface{}) []int {
if val, ok := configMap[configKeyStatusCodeIgnored]; ok {
if v, ok := val.([]int); ok {
return v
}
}
return []int{}
}