diff options
| author | Mitchell Riedstra <mitch@x230.my.domain> | 2021-07-11 11:55:47 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@x230.my.domain> | 2021-07-11 11:55:47 -0400 |
| commit | 1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d (patch) | |
| tree | 023701c9d033269d83be8415809b292ae1f3cee0 /cmd/server/main.go | |
| parent | e6d53f71c9718ecdb9fde16a924d75a71aadd2d2 (diff) | |
| download | go-website-1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d.tar.gz go-website-1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d.tar.xz | |
Initial banging away at adding an Atom feed to the site
Diffstat (limited to 'cmd/server/main.go')
| -rw-r--r-- | cmd/server/main.go | 26 |
1 files changed, 23 insertions, 3 deletions
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, |
