diff options
Diffstat (limited to 'model/config.go')
-rw-r--r-- | model/config.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/model/config.go b/model/config.go index 60a6d1983..b7888ab13 100644 --- a/model/config.go +++ b/model/config.go @@ -802,7 +802,8 @@ type RateLimitSettings struct { PerSec *int MaxBurst *int MemoryStoreSize *int - VaryByRemoteAddr bool + VaryByRemoteAddr *bool + VaryByUser *bool VaryByHeader string } @@ -822,6 +823,14 @@ func (s *RateLimitSettings) SetDefaults() { if s.MemoryStoreSize == nil { s.MemoryStoreSize = NewInt(10000) } + + if s.VaryByRemoteAddr == nil { + s.VaryByRemoteAddr = NewBool(true) + } + + if s.VaryByUser == nil { + s.VaryByUser = NewBool(false) + } } type PrivacySettings struct { @@ -1681,12 +1690,8 @@ func (o *Config) Clone() *Config { } func (o *Config) ToJson() string { - b, err := json.Marshal(o) - if err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(o) + return string(b) } func (o *Config) GetSSOService(service string) *SSOSettings { @@ -1703,14 +1708,9 @@ func (o *Config) GetSSOService(service string) *SSOSettings { } func ConfigFromJson(data io.Reader) *Config { - decoder := json.NewDecoder(data) - var o Config - err := decoder.Decode(&o) - if err == nil { - return &o - } else { - return nil - } + var o *Config + json.NewDecoder(data).Decode(&o) + return o } func (o *Config) SetDefaults() { |