MCPcopy
hub / github.com/gofiber/fiber / configDefault

Function configDefault

middleware/paginate/config.go:83–125  ·  view source on GitHub ↗
(config ...Config)

Source from the content-addressed store, hash-verified

81}
82
83func configDefault(config ...Config) Config {
84 if len(config) < 1 {
85 return ConfigDefault
86 }
87
88 cfg := config[0]
89
90 if cfg.Next == nil {
91 cfg.Next = ConfigDefault.Next
92 }
93 if cfg.PageKey == "" {
94 cfg.PageKey = ConfigDefault.PageKey
95 }
96 if cfg.DefaultLimit < 1 {
97 cfg.DefaultLimit = ConfigDefault.DefaultLimit
98 }
99 if cfg.LimitKey == "" {
100 cfg.LimitKey = ConfigDefault.LimitKey
101 }
102 if cfg.DefaultPage < 1 {
103 cfg.DefaultPage = ConfigDefault.DefaultPage
104 }
105 if cfg.CursorKey == "" {
106 cfg.CursorKey = ConfigDefault.CursorKey
107 }
108 if cfg.DefaultSort == "" {
109 cfg.DefaultSort = ConfigDefault.DefaultSort
110 }
111 if cfg.OffsetKey == "" {
112 cfg.OffsetKey = ConfigDefault.OffsetKey
113 }
114 if cfg.MaxLimit < 1 {
115 cfg.MaxLimit = ConfigDefault.MaxLimit
116 }
117 if cfg.DefaultLimit > cfg.MaxLimit {
118 cfg.DefaultLimit = cfg.MaxLimit
119 }
120 if len(cfg.AllowedSorts) > 0 && !slices.Contains(cfg.AllowedSorts, cfg.DefaultSort) {
121 cfg.DefaultSort = cfg.AllowedSorts[0]
122 }
123
124 return cfg
125}

Callers 7

Test_ConfigDefaultFunction · 0.70
Test_ConfigOverrideFunction · 0.70
NewFunction · 0.70

Calls 1

ContainsMethod · 0.80

Tested by 6

Test_ConfigDefaultFunction · 0.56
Test_ConfigOverrideFunction · 0.56