123456789101112131415161718192021 |
- package server
- import "time"
- // Config holds the server configuration
- type Config struct {
- Port int `yaml:"port"`
- RequestTimeout time.Duration `yaml:"request_timeout"` // in seconds
- AllowedOrigins []string `yaml:"allowed_origins"`
- }
- // Validate implements the config.Validator interface
- func (c *Config) Validate() error {
- if c.Port == 0 {
- c.Port = 8080
- }
- if c.RequestTimeout == 0 {
- c.RequestTimeout = 30 * time.Second
- }
- return nil
- }
|