From 1b1d3064c9064ca76ee629d07ff79fbdaffd31ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Antoli=C5=A1?= Date: Fri, 4 Sep 2020 21:59:07 +0200 Subject: [PATCH] Move cacheControl func into handle.go file --- cache.go | 8 -------- handle.go | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cache.go b/cache.go index 587b0c4..b1b1be9 100644 --- a/cache.go +++ b/cache.go @@ -11,7 +11,6 @@ package writefreely import ( - "net/http" "sync" "time" ) @@ -68,10 +67,3 @@ func GetPostsCache(userID int64) *[]PublicPost { } return pci.Posts } - -func cacheControl(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Cache-Control", "public, max-age=604800, immutable") - next.ServeHTTP(w, r) - }) -} diff --git a/handle.go b/handle.go index fe03757..5e15137 100644 --- a/handle.go +++ b/handle.go @@ -926,3 +926,10 @@ func sendRedirect(w http.ResponseWriter, code int, location string) int { w.WriteHeader(code) return code } + +func cacheControl(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Cache-Control", "public, max-age=604800, immutable") + next.ServeHTTP(w, r) + }) +}