This commit is contained in:
tumillanino
2025-10-28 12:36:37 +11:00
parent 186d6768fb
commit dad3ec655f
31 changed files with 2256 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package handlers
import (
"html/template"
"net/http"
"decor-by-hannahs/internal/db"
)
func CatalogHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
svcs, err := q.ListServices(r.Context())
if err != nil {
http.Error(w, "unable to load services", http.StatusInternalServerError)
return
}
type data struct {
Services []db.Service
ActivePage string
}
if err := tmpl.ExecuteTemplate(w, "catalog.tmpl", data{Services: svcs, ActivePage: "catalog"}); err != nil {
http.Error(w, "Failed to render page", http.StatusInternalServerError)
}
}
}