well-goknown/config/config.go

39 lines
951 B
Go
Raw Normal View History

2023-02-05 01:21:10 +00:00
package config
import (
"os"
)
type (
Config struct {
2023-04-29 18:01:40 +00:00
ListenAddr string
2023-05-03 02:12:18 +00:00
LndCertB64 string
LndAddr string
LndMacaroonHex string
2023-04-29 18:01:40 +00:00
LogLevel string
2023-02-05 01:21:10 +00:00
MatrixIdentityServer string
MatrixWellKnownAddress string
2023-04-29 18:01:40 +00:00
NostrAddrFee string
2023-02-05 01:21:10 +00:00
}
)
func GetConfig() Config {
return Config{
2023-04-29 18:01:40 +00:00
ListenAddr: getEnv("LISTEN_ADDR", ":8090"),
2023-05-03 02:12:18 +00:00
LndCertB64: getEnv("LND_CERT_B64", ""),
LndAddr: getEnv("LND_ADDR", ""),
LndMacaroonHex: getEnv("LND_MACAROON_HEX", ""),
2023-04-29 18:01:40 +00:00
LogLevel: getEnv("LOG_LEVEL", "INFO"),
2023-02-05 01:21:10 +00:00
MatrixIdentityServer: getEnv("MATRIX_IDENTITY_SERVER", ""),
MatrixWellKnownAddress: getEnv("MATRIX_WELL_KNOWN_ADDRESS", ""),
2023-04-29 18:01:40 +00:00
NostrAddrFee: getEnv("NOSTR_ADDR_FEE", ""),
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
}