feat(apps): auto-register app routes from DefaultApps
This commit is contained in:
parent
c24bdc4305
commit
29782180d9
1 changed files with 13 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue