diff options
author | Julio Capote <jcapote@gmail.com> | 2023-01-08 14:36:33 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2023-01-08 14:36:33 +0000 |
commit | fdcf534c7b0fbb3cdc511cf9f26f16cf677994a6 (patch) | |
tree | 2674d0e5937703802414fc2f63c60e6933770261 /main.go | |
parent | ff1d7ddc3f5e386b9c8107456c54ca5f985c7b4b (diff) | |
download | communique-fdcf534c7b0fbb3cdc511cf9f26f16cf677994a6.tar.gz |
config validation
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -9,6 +9,7 @@ import ( "git.capotej.com/capotej/communique/controller" "git.capotej.com/capotej/communique/http" "git.capotej.com/capotej/communique/models" + "github.com/BurntSushi/toml" "github.com/dgraph-io/badger/v3" "github.com/microcosm-cc/bluemonday" @@ -31,7 +32,12 @@ func main() { if err != nil { log.Fatal(err) } - log.Debugf("Loaded TOML Config: %+v", cfg) + log.Debugf("Loaded config: %+v", cfg) + err = cfg.Validate() + if err != nil { + log.Fatal(err) + } + log.Debugf("Validated Config: %+v", cfg) // DB dbOpts := badger.DefaultOptions(cfg.DbPath) @@ -59,7 +65,7 @@ func main() { persister := models.NewPersister(log, db) // Controller - controller, err := controller.NewController(cfg, persister, log) + registry, err := controller.NewController(cfg, persister, log) if err != nil { log.Fatal(err) } @@ -76,7 +82,7 @@ func main() { // // External Http Server writer := &zapio.Writer{Log: logger, Level: zap.DebugLevel} defer writer.Close() - router := http.NewRouter(controller, log) + router := http.NewRouter(registry, log) mainWg.Add(1) go router.Start(writer) |