Implement TLS support: update configuration for TLS, modify server to handle HTTPS, and enhance logging for request handling

This commit is contained in:
alex
2025-06-24 22:15:37 +03:00
parent 973c060e5f
commit ef1efdd585
8 changed files with 75 additions and 54 deletions

View File

@@ -12,6 +12,13 @@ type ConfigConf struct {
Mode string `yaml:"mode" env-default:"dev"`
ComDir string `yaml:"com_dir" env-default:"./com/"`
HTTPServer `yaml:"http_server"`
TLS `yaml:"tls"`
}
type TLS struct {
TlsEnabled string `yaml:"enabled" env-default:"false"`
CertFile string `yaml:"cert_file" env-default:"./cert/server.crt"`
KeyFile string `yaml:"key_file" env-default:"./cert/server.key"`
}
type HTTPServer struct {
@@ -31,6 +38,7 @@ type ConfigEnv struct {
}
func MustLoadConfig() *ConfigConf {
log.SetOutput(os.Stderr)
var configEnv ConfigEnv
if err := cleanenv.ReadEnv(&configEnv); err != nil {
log.Fatalf("Failed to read environment variables: %v", err)