graphicek/server/config/config.go

37 lines
639 B
Go
Raw Normal View History

2022-08-13 23:33:50 +02:00
package config
import (
"os"
"strconv"
2022-08-13 23:33:50 +02:00
)
type Config struct {
2022-08-21 20:51:14 +02:00
Mode string
DatabaseUrl string
Port int
Ip string
AuthUsername string
AuthPassword string
AuthKey string
2022-08-13 23:33:50 +02:00
}
func LoadConfig() *Config {
port, err := strconv.Atoi(os.Getenv("PORT"))
2022-08-13 23:33:50 +02:00
if err != nil {
panic(err)
}
config := Config{
Mode: os.Getenv("GIN_MODE"),
DatabaseUrl: os.Getenv("DATABASE_URL"),
Port: port,
Ip: os.Getenv("BIND_IP"),
AuthUsername: os.Getenv("AUTH_USERNAME"),
AuthPassword: os.Getenv("AUTH_PASSWORD"),
2022-08-21 20:51:14 +02:00
AuthKey: os.Getenv("SENSOR_AUTH_KEY"),
2022-08-13 23:33:50 +02:00
}
return &config
}