diff --git a/pages.go b/pages.go index 1bbb920..6c7576c 100644 --- a/pages.go +++ b/pages.go @@ -39,12 +39,13 @@ func serveFile(username string, path string, giteaClient *gitea.Client, w http.R entry, found := pageCache.Get(key) var content []byte var mimeType string + var err error if found { log.Debugf("Returning %s from cache", path) content = entry.(PageContentCache).Content mimeType = entry.(PageContentCache).mimeType } else { - content, _, err := giteaClient.GetFile(username, "pages", PagesBranch, path, false) + content, _, err = giteaClient.GetFile(username, "pages", PagesBranch, path, false) if err != nil { log.Errorf("Failed to get file %s (%s)", path, err) w.WriteHeader(404) @@ -53,7 +54,7 @@ func serveFile(username string, path string, giteaClient *gitea.Client, w http.R pathParts := strings.Split(path, ".") ext := pathParts[len(pathParts) - 1] - mimeType := mime.TypeByExtension("." + ext) + mimeType = mime.TypeByExtension("." + ext) pageCache.Set( key, @@ -63,8 +64,10 @@ func serveFile(username string, path string, giteaClient *gitea.Client, w http.R }, cache.DefaultExpiration, ) + + log.Debugf("Page %s requested from Gitea and cached in memory", path) } - + w.WriteHeader(200) w.Header().Set("Content-Type", mimeType) w.Write(content)