You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
471 B
Go
36 lines
471 B
Go
package config
|
|
|
|
import (
|
|
"git.phc.dm.unipi.it/phc/website/sl"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
var Slot = sl.NewSlot[*Config]()
|
|
|
|
type Config struct {
|
|
Mode string
|
|
Host string
|
|
}
|
|
|
|
func Load(l *sl.ServiceLocator) (*Config, error) {
|
|
m, err := godotenv.Read(".env")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
mode := "production"
|
|
if v, ok := m["MODE"]; ok {
|
|
mode = v
|
|
}
|
|
host := ":4000"
|
|
if v, ok := m["HOST"]; ok {
|
|
host = v
|
|
}
|
|
|
|
return &Config{
|
|
mode,
|
|
host,
|
|
}, nil
|
|
}
|