2026-09-19 17:33:44 +02:00
|
|
|
// Package config carries the runtime settings for the demo CMS. There is no
|
|
|
|
|
// database to configure: content is seeded in memory and optionally mirrored to
|
|
|
|
|
// a single JSON file.
|
2026-09-19 14:17:27 +02:00
|
|
|
package config
|
|
|
|
|
|
2026-09-19 17:33:44 +02:00
|
|
|
import "os"
|
2026-09-19 14:17:27 +02:00
|
|
|
|
|
|
|
|
type Config struct {
|
2026-09-19 17:33:44 +02:00
|
|
|
HTTPAddr, Profile, ContentFile, PostgresURL string
|
2026-09-19 16:45:24 +02:00
|
|
|
AllowedOrigins, SSOHeader, SSOToken, SSOCookie string
|
2026-09-19 14:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-19 16:45:24 +02:00
|
|
|
func Load() Config {
|
2026-09-19 14:48:42 +02:00
|
|
|
return Config{
|
2026-09-19 17:33:44 +02:00
|
|
|
HTTPAddr: get("CMS_HTTP_ADDR", ":8080"),
|
|
|
|
|
Profile: get("CMS_PROFILE", "demo"),
|
|
|
|
|
ContentFile: get("CMS_CONTENT_FILE", ""),
|
|
|
|
|
PostgresURL: get("CMS_POSTGRES_URL", ""),
|
|
|
|
|
AllowedOrigins: get("CMS_ALLOWED_ORIGINS", "http://localhost:5173"),
|
|
|
|
|
SSOHeader: get("CMS_SSO_HEADER", "X-SSO-Token"),
|
|
|
|
|
SSOToken: get("CMS_SSO_TOKEN", ""),
|
|
|
|
|
SSOCookie: get("CMS_SSO_COOKIE", ""),
|
2026-09-19 14:48:42 +02:00
|
|
|
}
|
2026-09-19 14:17:27 +02:00
|
|
|
}
|
2026-09-19 16:45:24 +02:00
|
|
|
|
2026-09-19 14:17:27 +02:00
|
|
|
func get(k, d string) string {
|
|
|
|
|
if v := os.Getenv(k); v != "" {
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
return d
|
|
|
|
|
}
|