From 268fcf7e6b671d4959a12111d5abf553bf0a201b Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sun, 24 Oct 2021 12:52:38 -0400 Subject: Redis caching. Linter config and cleanup. --- cmd/server/app.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'cmd/server/app.go') 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 } -- cgit v1.2.3