2026-05-29 15:48:11 +00:00
|
|
|
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"`
|
2026-08-08 02:24:08 -06:00
|
|
|
|
|
|
|
|
// 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:","`
|
2026-05-29 15:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaultShutdownTimeout = 10 * time.Second
|