From 1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sun, 11 Jul 2021 11:55:47 -0400 Subject: Initial banging away at adding an Atom feed to the site --- cmd/server/main.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'cmd/server/main.go') diff --git a/cmd/server/main.go b/cmd/server/main.go index 9ec96da..b2a95c3 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "gopkg.in/yaml.v3" "log" "net/http" "os" @@ -18,6 +19,18 @@ func VersionPrint() { os.Exit(0) } +func loadConf(fn string) (*App, error) { + fh, err := os.Open(fn) + if err != nil { + return nil, err + } + dec := yaml.NewDecoder(fh) + + app := &App{} + err = dec.Decode(app) + return app, err +} + func main() { fl := flag.NewFlagSet("Website", flag.ExitOnError) listen := fl.String("l", "0.0.0.0:8001", "Listening address") @@ -36,11 +49,18 @@ func main() { log.Fatal(err) } - app := &App{ - ReIndexPath: *indexPath, - StaticDirectory: "static", + app, err := loadConf("conf.yml") + if err != nil { + log.Println(err) + app = &App{} } + app.ReIndexPath = *indexPath + app.StaticDirectory = "static" + + b, _ := yaml.Marshal(app) + os.Stderr.Write(b) + srv := &http.Server{ Handler: app, Addr: *listen, -- cgit v1.2.3