2024-08-30 16:06:19 +02:00
|
|
|
package calls
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
b "streifling.com/jason/cpolis/cmd/backend"
|
2024-10-30 03:24:29 +01:00
|
|
|
f "streifling.com/jason/cpolis/cmd/frontend"
|
2024-08-30 16:06:19 +02:00
|
|
|
)
|
|
|
|
|
2025-01-14 20:53:49 +01:00
|
|
|
func ServeImage(c *b.Config, s map[string]*f.Session) http.HandlerFunc {
|
2024-08-30 16:06:19 +02:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2025-01-19 20:34:12 +01:00
|
|
|
if !f.SessionIsActive(r, s) {
|
2024-10-30 03:24:29 +01:00
|
|
|
if !tokenIsVerified(w, r, c) {
|
|
|
|
return
|
|
|
|
}
|
2024-08-30 21:20:29 +02:00
|
|
|
}
|
2024-08-30 16:06:19 +02:00
|
|
|
|
2025-01-19 20:10:06 +01:00
|
|
|
http.ServeFile(w, r, filepath.Join(c.ImgDir, r.PathValue("pic")))
|
2024-08-30 16:06:19 +02:00
|
|
|
}
|
|
|
|
}
|