-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
47 lines (36 loc) · 720 Bytes
/
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
package sensitive
import (
"github.com/gofiber/fiber/v2"
)
type Config struct {
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
// Required. Default: []
Keys []string
// Optional. Default: "x"
Mark string
// Optional. Default: false
DebugMode bool
}
var ConfigDefault = Config{
Next: nil,
Keys: []string{},
Mark: "x",
DebugMode: false,
}
func configDefault(config ...Config) Config {
// Return default config if nothing provided
if len(config) < 1 {
return ConfigDefault
}
// Override default config
cfg := config[0]
// set default values
if cfg.Keys == nil {
cfg.Keys = ConfigDefault.Keys
}
if cfg.Mark == "" {
cfg.Mark = ConfigDefault.Mark
}
return cfg
}