aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/app.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-10-24 12:52:38 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-10-24 12:52:38 -0400
commit268fcf7e6b671d4959a12111d5abf553bf0a201b (patch)
tree6f5c46c9a765478eaae78d66f4b9aefc953bbd1a /cmd/server/app.go
parentd36b6a55c8fa4400cd39de717443e110e990a8a3 (diff)
downloadgo-website-268fcf7e6b671d4959a12111d5abf553bf0a201b.tar.gz
go-website-268fcf7e6b671d4959a12111d5abf553bf0a201b.tar.xz
Redis caching. Linter config and cleanup.
Diffstat (limited to 'cmd/server/app.go')
-rw-r--r--cmd/server/app.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/cmd/server/app.go b/cmd/server/app.go
index 743a389..290b44a 100644
--- a/cmd/server/app.go
+++ b/cmd/server/app.go
@@ -1,8 +1,10 @@
package main
import (
+ "fmt"
"os"
+ "github.com/gomodule/redigo/redis"
"gopkg.in/yaml.v3"
"riedstra.dev/mitch/go-website/page"
)
@@ -10,6 +12,8 @@ import (
var FeedPrefixDefault = ".feeds"
type App struct {
+ redisPool *redis.Pool
+
ReIndexPath string
StaticDirectory string
BaseTemplate string
@@ -21,7 +25,7 @@ type App struct {
Description string // aka, "subtitle"
Author Author
SiteURL string
- FeedId string
+ FeedId string //nolint
Updated page.PageTime
FeedPrefix string
}
@@ -29,28 +33,34 @@ type App struct {
func loadConf(fn string) (*App, error) {
fh, err := os.Open(fn)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("loading config: %w", err)
}
+
dec := yaml.NewDecoder(fh)
app := &App{}
+
err = dec.Decode(app)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("decoding yaml: %w", err)
}
if app.StaticDirectory == "" {
app.StaticDirectory = "static"
}
+
if app.FeedPrefix == "" {
app.FeedPrefix = FeedPrefixDefault
}
+
if app.BaseTemplate != "" {
page.BaseTemplate = app.BaseTemplate
}
+
if app.DocumentSplit != "" {
page.DocumentSplit = app.DocumentSplit
}
+
if app.Suffix != "" {
page.Suffix = app.Suffix
}