initial commit

This commit is contained in:
Krzysztof
2025-08-01 18:01:55 +02:00
commit 9af1af7f92
73 changed files with 6531 additions and 0 deletions

28
handler/home_handler.go Normal file
View File

@@ -0,0 +1,28 @@
package handler
import (
"html/template"
"net/http"
"uptimemonitor"
"uptimemonitor/html"
)
func (h *Handler) HomePage() http.HandlerFunc {
tmpl := template.Must(template.ParseFS(html.FS, "layout.html", "app.html", "home.html"))
type data struct {
User uptimemonitor.User
}
return func(w http.ResponseWriter, r *http.Request) {
count := h.Store.CountMonitors(r.Context())
if count == 0 {
http.Redirect(w, r, "/new", http.StatusSeeOther)
return
}
tmpl.Execute(w, data{
User: getUserFromRequest(r),
})
}
}