39 lines
742 B
Go
39 lines
742 B
Go
package config
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func GetEnv() string {
|
|
return getEnvironmentValue("ENV")
|
|
}
|
|
|
|
func GetInfoDataSourceURL() string {
|
|
return getEnvironmentValue("INFO_DATA_SOURCE_URL")
|
|
}
|
|
func GetPhotoDataSourceURL() string {
|
|
return getEnvironmentValue("PHOTO_DATA_SOURCE_URL")
|
|
}
|
|
|
|
func GetApplicationPort() int {
|
|
portStr := getEnvironmentValue("APPLICATION_PORT")
|
|
port, err := strconv.Atoi(portStr)
|
|
if err != nil {
|
|
log.Fatalf("port: %s is invalid", portStr)
|
|
}
|
|
return port
|
|
}
|
|
|
|
func GetNatsServiceUrl() string {
|
|
return getEnvironmentValue("NATS_SERVICE_URL")
|
|
}
|
|
|
|
func getEnvironmentValue(key string) string {
|
|
if os.Getenv(key) == "" {
|
|
log.Fatalf("%s environment variable is missing.", key)
|
|
}
|
|
return os.Getenv(key)
|
|
}
|