aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/main.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@x230.my.domain>2021-07-11 11:55:47 -0400
committerMitchell Riedstra <mitch@x230.my.domain>2021-07-11 11:55:47 -0400
commit1c6c1f1597b71f4d4f3a1722655b8864c0d33e6d (patch)
tree023701c9d033269d83be8415809b292ae1f3cee0 /cmd/server/main.go
parente6d53f71c9718ecdb9fde16a924d75a71aadd2d2 (diff)
downloadgo-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.go26
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,