package handlers import ( "html/template" "net/http" ory "github.com/ory/client-go" "decor-by-hannahs/internal/db" ) func CatalogHandler(q *db.Queries, tmpl *template.Template, oryClient *ory.APIClient) 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 Authenticated bool OryLoginURL string } if err := tmpl.ExecuteTemplate(w, "catalog.tmpl", data{ Services: svcs, ActivePage: "catalog", Authenticated: isAuthenticated(r, oryClient), OryLoginURL: "/login", }); err != nil { http.Error(w, "Failed to render page", http.StatusInternalServerError) } } }