aboutsummaryrefslogtreecommitdiff
path: root/src/conf
diff options
context:
space:
mode:
authorAlexander Kavon <hawk@alexkavon.com>2023-11-27 14:48:44 -0500
committerAlexander Kavon <hawk@alexkavon.com>2023-11-27 14:48:44 -0500
commit1d05f918887e9ba4576149513e5df0bb57e6bd72 (patch)
tree2f5e94e21f90183509fe1ae52905c47d67a3c5d0 /src/conf
parent8a30281eff35623d1a68642e4d94c814d1b47a0c (diff)
config updates, rename user model, load auth routes, initial templating poc
Diffstat (limited to 'src/conf')
-rw-r--r--src/conf/conf.go34
1 files changed, 20 insertions, 14 deletions
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
}