well-goknown/config/config.go
2023-04-29 14:01:40 -04:00

33 lines
693 B
Go

package config
import (
"os"
)
type (
Config struct {
ListenAddr string
LogLevel string
MatrixIdentityServer string
MatrixWellKnownAddress string
NostrAddrFee string
}
)
func GetConfig() Config {
return Config{
ListenAddr: getEnv("LISTEN_ADDR", ":8090"),
LogLevel: getEnv("LOG_LEVEL", "INFO"),
MatrixIdentityServer: getEnv("MATRIX_IDENTITY_SERVER", ""),
MatrixWellKnownAddress: getEnv("MATRIX_WELL_KNOWN_ADDRESS", ""),
NostrAddrFee: getEnv("NOSTR_ADDR_FEE", ""),
}
}
func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}