Change structure of code tor frontend and backend one

This commit is contained in:
2024-07-13 13:58:36 +02:00
parent 21fd3403b2
commit d0c1e525d2
18 changed files with 197 additions and 126 deletions

22
cmd/frontend/images.go Normal file
View File

@ -0,0 +1,22 @@
package frontend
import (
"log"
"net/http"
"path/filepath"
"streifling.com/jason/cpolis/cmd/backend"
)
func ServeImage(c *backend.Config, s *backend.CookieStore) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
absFilepath, err := filepath.Abs(c.PicsDir)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.ServeFile(w, r, absFilepath+"/"+r.PathValue("pic"))
}
}