Files
web/server/config.go
T

23 lines
1.1 KiB
Go

package server
import "time"
// Config holds HTTP server configuration.
// All fields carry caarlos0/env struct tags — applications supply the loader.
type Config struct {
Host string `env:"EINHERJAR_SERVER_HOST" envDefault:"0.0.0.0"`
Port int `env:"EINHERJAR_SERVER_PORT" envDefault:"8080"`
ReadTimeout time.Duration `env:"EINHERJAR_SERVER_READ_TIMEOUT" envDefault:"5s"`
WriteTimeout time.Duration `env:"EINHERJAR_SERVER_WRITE_TIMEOUT" envDefault:"10s"`
IdleTimeout time.Duration `env:"EINHERJAR_SERVER_IDLE_TIMEOUT" envDefault:"120s"`
ShutdownTimeout time.Duration `env:"EINHERJAR_SERVER_SHUTDOWN_TIMEOUT" envDefault:"10s"`
// CORSOrigins is the allowed cross-origin list (comma-separated in the env var).
// web.New applies mw.CORS with it automatically; callers of server.New pass it to
// mw.CORS themselves. "*" is rejected by mw.CORS — use mw.CORSAllowAll for allow-all
// (development only).
CORSOrigins []string `env:"EINHERJAR_SERVER_CORS_ORIGINS" envSeparator:","`
}
const defaultShutdownTimeout = 10 * time.Second