Initial commit

This commit is contained in:
2023-05-14 19:44:16 +02:00
commit 15bc406494
29 changed files with 4346 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package config
import (
"git.phc.dm.unipi.it/phc/website/libs/sl"
"github.com/joho/godotenv"
)
var Slot = sl.NewSlot[Config]()
var TestingProductionConfig = Config{
Mode: "production",
Host: ":4000",
}
var TestingDevelopmentConfig = Config{
Mode: "development",
Host: ":4000",
}
type Config struct {
Mode string
Host string
}
func Load(l *sl.ServiceLocator) (Config, error) {
m, err := godotenv.Read(".env")
if err != nil {
return Config{}, err
}
var cfg Config
cfg.Mode = "production"
if v, ok := m["MODE"]; ok {
cfg.Mode = v
}
cfg.Host = ":4000"
if v, ok := m["HOST"]; ok {
cfg.Host = v
}
return cfg, nil
}