aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/main.go
diff options
context:
space:
mode:
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,