Serve images from only one route enabling image previews in articles

This commit is contained in:
2024-10-30 03:24:29 +01:00
parent b4003c8216
commit b7d82f15e9
11 changed files with 41 additions and 59 deletions

View File

@ -6,12 +6,15 @@ import (
"path/filepath"
b "streifling.com/jason/cpolis/cmd/backend"
f "streifling.com/jason/cpolis/cmd/frontend"
)
func ServeImage(c *b.Config) http.HandlerFunc {
func ServeImage(c *b.Config, s *b.CookieStore) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !tokenIsVerified(w, r, c) {
return
if _, err := f.GetSession(w, r, c, s); err != nil {
if !tokenIsVerified(w, r, c) {
return
}
}
absFilepath, err := filepath.Abs(c.PicsDir)