mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-09-08 15:41:18 +02:00
removed unnecessery empty array normalizations because encoding/json/v2 does it by default
This commit is contained in:
@@ -581,18 +581,6 @@ type TrustedProxyConfig struct {
|
|||||||
UseLeftmostIP bool `form:"useLeftmostIP" json:"useLeftmostIP"`
|
UseLeftmostIP bool `form:"useLeftmostIP" json:"useLeftmostIP"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the [json.Marshaler] interface.
|
|
||||||
func (c TrustedProxyConfig) MarshalJSON() ([]byte, error) {
|
|
||||||
type alias TrustedProxyConfig
|
|
||||||
|
|
||||||
// serialize as empty array
|
|
||||||
if c.Headers == nil {
|
|
||||||
c.Headers = []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
return json.Marshal(alias(c))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate makes RateLimitRule validatable by implementing [validation.Validatable] interface.
|
// Validate makes RateLimitRule validatable by implementing [validation.Validatable] interface.
|
||||||
func (c TrustedProxyConfig) Validate() error {
|
func (c TrustedProxyConfig) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
@@ -640,21 +628,6 @@ func (c *RateLimitsConfig) FindRateLimitRule(searchLabels []string, optOnlyAudie
|
|||||||
return RateLimitRule{}, false
|
return RateLimitRule{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the [json.Marshaler] interface.
|
|
||||||
func (c RateLimitsConfig) MarshalJSON() ([]byte, error) {
|
|
||||||
type alias RateLimitsConfig
|
|
||||||
|
|
||||||
// serialize as empty array
|
|
||||||
if c.Rules == nil {
|
|
||||||
c.Rules = []RateLimitRule{}
|
|
||||||
}
|
|
||||||
if c.ExcludedIPs == nil {
|
|
||||||
c.ExcludedIPs = []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
return json.Marshal(alias(c))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate makes RateLimitsConfig validatable by implementing [validation.Validatable] interface.
|
// Validate makes RateLimitsConfig validatable by implementing [validation.Validatable] interface.
|
||||||
func (c RateLimitsConfig) Validate() error {
|
func (c RateLimitsConfig) Validate() error {
|
||||||
return validation.ValidateStruct(&c,
|
return validation.ValidateStruct(&c,
|
||||||
|
|||||||
Reference in New Issue
Block a user