well-goknown/config/config.go
2024-02-11 21:27:05 -05:00

41 lines
1 KiB
Go

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