Add files via upload

This commit is contained in:
Tomáš Dvořák
2025-05-26 11:19:42 +02:00
committed by GitHub
parent 71730d201b
commit d3581993a7
4 changed files with 1389 additions and 2 deletions
+21
View File
@@ -80,6 +80,27 @@ func main() {
time.Sleep(2 * time.Second)
http.Redirect(w, r, "http://webportal:8080/", http.StatusFound)
}))
// Authentication routes
http.HandleFunc("/login", enableCORS(handleLogin))
http.HandleFunc("/logout", enableCORS(handleLogout))
// Admin routes (protected)
http.HandleFunc("/admin", enableCORS(requireAdminAuth(handleAdmin)))
http.HandleFunc("/admin/cards", enableCORS(requireAdminAuth(handleAdminCards)))
http.HandleFunc("/admin/cards/", enableCORS(requireAdminAuth(func(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
if strings.HasSuffix(path, "/toggle") {
handleAdminCardToggle(w, r)
} else if r.Method == "DELETE" {
handleAdminCardDelete(w, r)
} else {
w.WriteHeader(http.StatusNotFound)
}
})))
// Public API to get cards for homepage
http.HandleFunc("/api/cards", enableCORS(handleGetCards))
port := os.Getenv("PORT")
if port == "" {