This commit is contained in:
flo_isea committed 2026-04-20 20:11:43 +02:00
1 parent 17baba1490
commit 4fcefd7fb7
4 files changed
+38

No files matched your search

+17
View File
@@ -28,6 +28,7 @@ func New(secret string, chartMax int, st *store.Store, templates fs.FS) *Server
func (s *Server) Routes() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/", s.handleIndex)
mux.HandleFunc("/logo.png", s.handleLogo)
mux.HandleFunc("/favicon.svg", s.handleFavicon)
mux.HandleFunc("/write", s.handleWrite)
return mux
@@ -70,6 +71,22 @@ func (s *Server) handleFavicon(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(faviconSVG))
}
func (s *Server) handleLogo(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/logo.png" {
http.NotFound(w, r)
return
}
data, err := fs.ReadFile(s.templates, "static/logo.png")
if err != nil {
http.Error(w, "asset missing", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "image/png")
_, _ = w.Write(data)
}
func (s *Server) handleWrite(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)