From 1d05f918887e9ba4576149513e5df0bb57e6bd72 Mon Sep 17 00:00:00 2001 From: Alexander Kavon Date: Mon, 27 Nov 2023 14:48:44 -0500 Subject: config updates, rename user model, load auth routes, initial templating poc --- src/conf/conf.go | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/conf/conf.go') diff --git a/src/conf/conf.go b/src/conf/conf.go index f68c2f4..8abb8a8 100644 --- a/src/conf/conf.go +++ b/src/conf/conf.go @@ -9,40 +9,46 @@ import ( type ( Conf struct { - Db Db - Server Server + Db Db `toml:"database"` + Server Server `toml:"server"` } Db struct { - Adapter string `toml:"DB_ADAPTER"` - User string `toml:"DB_USER"` - Password string `toml:"DB_PASS"` + Adapter string `toml:"adapter"` + User string `toml:"user"` + Password string `toml:"pass"` } Server struct { - Hostname string `toml:"SERVER_HOSTNAME"` - Port string `toml:"SERVER_PORT"` + Hostname string `toml:"hostname"` + Port string `toml:"port"` + TemplatePath string `toml:"template_path"` } ) func NewConf() *Conf { + workingdir, err := os.Getwd() + if err != nil { + log.Fatal(err) + } filepath := os.Getenv("NEWSSTAND_CONFIG_PATH") if filepath == "" { - workingdir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } filepath = workingdir + "/.newsstandrc.toml" } log.Printf("Config file path: %s", filepath) - var c Conf - _, err := toml.DecodeFile(filepath, &c) + c := Conf{ + Db{}, + Server{ + TemplatePath: workingdir + "/views", + }, + } + _, err = toml.DecodeFile(filepath, &c) if err != nil { log.Fatalln(err) } - log.Println(c.Db.Adapter) + log.Printf("Config loaded: %s", c) return &c } -- cgit v1.2.3