feat(apps): auto-register app routes from DefaultApps

This commit is contained in:
Claus Lohmar 2026-06-15 19:34:36 +00:00
parent c24bdc4305
commit 29782180d9

View file

@ -29,6 +29,19 @@ func (h *Handler) RegisterRoutes(mux *http.ServeMux, authGate func(http.Handler)
staticDir := filepath.Join(h.appDir, "static")
mux.Handle("GET /static/", http.StripPrefix("/static", http.FileServer(http.Dir(staticDir))))
mux.Handle("GET /", authGate(http.HandlerFunc(h.launcherPage)))
// App routes
for _, a := range DefaultApps("") {
if a.URL != "" && a.URL != "#" && a.URL != "/" && a.URL != "/admin" {
mux.Handle("GET "+a.URL, authGate(http.HandlerFunc(h.appPage(a.Name, a.Icon, a.Description))))
}
}
}
func (h *Handler) appPage(name, icon, desc string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
component := AppPage(name, icon, desc)
component.Render(r.Context(), w)
}
}
func (h *Handler) launcherPage(w http.ResponseWriter, r *http.Request) {