/
cloudservices
/
auth-service
Обзор
Документация
Войти
/
cloudservices
/
auth-service
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
pkg/xhttp/config.go
37 строк
914 B
Ivan Shibkikh
move http server to xhttp
27 июл 2026, 21:56
27 июл 2026, 21:56
1fb71b8
Код
Авторство
О чём код?
package xhttp import ( "errors" "time" ) type Config struct { Addr string `yaml:"addr"` ReadTimeout time.Duration `yaml:"read_timeout"` ReadHeaderTimeout time.Duration `yaml:"read_header_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` IdleTimeout time.Duration `yaml:"idle_timeout"` MaxHeaderBytes int `yaml:"max_header_bytes"` TLS TLSConfig `yaml:"tls"` } type TLSConfig struct { Enabled bool `yaml:"enabled"` CertFile string `yaml:"cert_file"` KeyFile string `yaml:"key_file"` } func (cfg Config) Validate() error { if cfg.Addr == "" { return errors.New("http addr cannot be empty") } if cfg.TLS.Enabled { if cfg.TLS.CertFile == "" { return errors.New("http tls.cert_file cannot be empty") } if cfg.TLS.KeyFile == "" { return errors.New("http tls.key_file cannot be empty") } } return nil }