cpolis/cmd/calls/images.go

22 lines
462 B
Go
Raw Normal View History

2024-08-30 16:06:19 +02:00
package calls
import (
"net/http"
"path/filepath"
b "streifling.com/jason/cpolis/cmd/backend"
f "streifling.com/jason/cpolis/cmd/frontend"
2024-08-30 16:06:19 +02: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) {
if _, err := f.ManageSession(w, r, c, s); err != nil {
if !tokenIsVerified(w, r, c) {
return
}
}
2024-08-30 16:06:19 +02:00
http.ServeFile(w, r, filepath.Join(c.PicsDir, r.PathValue("pic")))
2024-08-30 16:06:19 +02:00
}
}