well-goknown/config/config.go

35 lines
845 B
Go
Raw Normal View History

2023-02-05 01:21:10 +00:00
package config
import (
"os"
)
type (
Config struct {
2024-08-10 23:55:16 +00:00
DbUrl string
2023-04-29 18:01:40 +00:00
ListenAddr string
LogLevel string
2023-02-05 01:21:10 +00:00
MatrixIdentityServer string
2024-02-12 02:27:05 +00:00
MatrixMsc3575Address string
2024-08-10 23:55:16 +00:00
MatrixWellKnownAddress string
2023-02-05 01:21:10 +00:00
}
)
func GetConfig() Config {
return Config{
2024-08-10 23:55:16 +00:00
DbUrl: getEnv("DATABASE_URL", "postgres://user:password@127.0.0.1:5432/db?sslmode=disable"),
2023-04-29 18:01:40 +00:00
ListenAddr: getEnv("LISTEN_ADDR", ":8090"),
LogLevel: getEnv("LOG_LEVEL", "INFO"),
2023-02-05 01:21:10 +00:00
MatrixIdentityServer: getEnv("MATRIX_IDENTITY_SERVER", ""),
2024-02-12 02:27:05 +00:00
MatrixMsc3575Address: getEnv("MATRIX_MSC3575_ADDRESS", ""),
2024-08-10 23:55:16 +00:00
MatrixWellKnownAddress: getEnv("MATRIX_WELL_KNOWN_ADDRESS", ""),
2023-02-05 01:21:10 +00:00
}
}
func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}