add: Rate limiting & tests
This commit is contained in:
@@ -48,6 +48,12 @@ type RecipientsConfig struct {
|
||||
UserRegistration string `json:"UserRegistration" envconfig:"RECIPIENT_USER_REGISTRATION"`
|
||||
}
|
||||
|
||||
type SecurityConfig struct {
|
||||
Ratelimits struct {
|
||||
Limit int `json:"Limit" default:"1" envconfig:"RATE_LIMIT"`
|
||||
Burst int `json:"Burst" default:"60" envconfig:"BURST_LIMIT"`
|
||||
} `json:"RateLimits"`
|
||||
}
|
||||
type Config struct {
|
||||
Auth AuthenticationConfig `json:"auth"`
|
||||
Templates TemplateConfig `json:"templates"`
|
||||
@@ -56,6 +62,7 @@ type Config struct {
|
||||
BaseURL string `json:"BaseUrl" envconfig:"BASE_URL"`
|
||||
DB DatabaseConfig `json:"db"`
|
||||
SMTP SMTPConfig `json:"smtp"`
|
||||
Security SecurityConfig `json:"security"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -67,6 +74,7 @@ var (
|
||||
Templates TemplateConfig
|
||||
SMTP SMTPConfig
|
||||
Recipients RecipientsConfig
|
||||
Security SecurityConfig
|
||||
)
|
||||
|
||||
// LoadConfig initializes the configuration by reading from a file and environment variables.
|
||||
@@ -94,6 +102,7 @@ func LoadConfig() {
|
||||
SMTP = CFG.SMTP
|
||||
BaseURL = CFG.BaseURL
|
||||
Recipients = CFG.Recipients
|
||||
Security = CFG.Security
|
||||
}
|
||||
|
||||
// readFile reads the configuration from the specified file path into the provided Config struct.
|
||||
|
||||
Reference in New Issue
Block a user