add: contactController,tests & refactored tests

This commit is contained in:
$(pass /github/name)
2024-08-18 14:17:17 +02:00
parent 6441ad3ef9
commit ae0ec8bf88
17 changed files with 886 additions and 320 deletions

View File

@@ -43,23 +43,30 @@ type TemplateConfig struct {
StaticPath string `json:"StaticPath" default:"templates/css" envconfig:"TEMPLATE_STATIC_PATH"`
}
type RecipientsConfig struct {
ContactForm string `json:"ContactForm" envconfig:"RECIPIENT_CONTACT_FORM"`
UserRegistration string `json:"UserRegistration" envconfig:"RECIPIENT_USER_REGISTRATION"`
}
type Config struct {
ConfigFilePath string `json:"config_file_path" envconfig:"CONFIG_FILE_PATH"`
BaseURL string `json:"base_url" envconfig:"BASE_URL"`
Auth AuthenticationConfig `json:"auth"`
DB DatabaseConfig `json:"db"`
Templates TemplateConfig `json:"templates"`
Recipients RecipientsConfig `json:"recipients"`
ConfigFilePath string `json:"config_file_path" envconfig:"CONFIG_FILE_PATH"`
BaseURL string `json:"BaseUrl" envconfig:"BASE_URL"`
DB DatabaseConfig `json:"db"`
SMTP SMTPConfig `json:"smtp"`
}
var (
BaseURL string
CFGPath string
CFG Config
Auth AuthenticationConfig
DB DatabaseConfig
Templates TemplateConfig
SMTP SMTPConfig
BaseURL string
CFGPath string
CFG Config
Auth AuthenticationConfig
DB DatabaseConfig
Templates TemplateConfig
SMTP SMTPConfig
Recipients RecipientsConfig
)
// LoadConfig initializes the configuration by reading from a file and environment variables.
@@ -86,6 +93,7 @@ func LoadConfig() {
Templates = CFG.Templates
SMTP = CFG.SMTP
BaseURL = CFG.BaseURL
Recipients = CFG.Recipients
}
// readFile reads the configuration from the specified file path into the provided Config struct.