From 97dd660925434be537cd9a49a1d0c893b223e357 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Fri, 6 Jan 2023 01:22:38 -0500 Subject: Refactor routing and handlers We were building a new gorilla mux on each connection, change that to an *http.ServeMux and build it once for the lifetime of the application. Tell redis to only cache GET requests. --- cmd/server/app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cmd/server/app.go') diff --git a/cmd/server/app.go b/cmd/server/app.go index d4977ab..9a00628 100644 --- a/cmd/server/app.go +++ b/cmd/server/app.go @@ -36,6 +36,10 @@ type App struct { FeedPrefix string } +func newApp() *App { + return &App{} +} + func loadConf(fn string) (*App, error) { fh, err := os.Open(fn) if err != nil { @@ -44,7 +48,7 @@ func loadConf(fn string) (*App, error) { dec := yaml.NewDecoder(fh) - app := &App{} + app := newApp() err = dec.Decode(app) if err != nil { -- cgit v1.2.3