From 112e5071db042aa9231ba65f292872e793f6d263 Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Tue, 15 Oct 2024 14:56:59 -0500 Subject: [PATCH] iterate over every app to get router --- rest/router.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rest/router.go b/rest/router.go index 77a37b7..10d566f 100644 --- a/rest/router.go +++ b/rest/router.go @@ -25,9 +25,9 @@ func (c *Context) getRouter(assets fs.FS, indexHtml []byte) *http.ServeMux { mux.Handle("/api/upgrade", http.HandlerFunc(c.upgrade)) mux.Handle("/", returnIndexOrNotFound(indexHtml)) - // endpoints with no authentication (observability) - if c.ServerType == SERVER_TYPE_OBSERVABILITY { - mux.Handle("/api/observability/", c.Apps.Clients["observability"].GetRouter()) + // endpoints for apps + for appName, app := range c.Apps.Clients { + mux.Handle("/api/"+appName+"/", app.GetRouter()) } // scim @@ -39,11 +39,6 @@ func (c *Context) getRouter(assets fs.FS, indexHtml []byte) *http.ServeMux { mux.Handle("/api/profile/factors", c.authMiddleware(c.injectUserMiddleware(http.HandlerFunc(c.profileFactorsHandler)))) mux.Handle("/api/profile/factors/{name}", c.authMiddleware(c.injectUserMiddleware(http.HandlerFunc(c.profileFactorsHandler)))) - // endpoint with authentication (VPN) - if c.ServerType == SERVER_TYPE_VPN { - mux.Handle("/api/vpn/", c.authMiddleware(c.injectUserMiddleware(c.Apps.Clients["vpn"].GetRouter()))) - } - // endpoints with authentication, with admin role mux.Handle("/api/license", c.authMiddleware(c.injectUserMiddleware(c.isAdminMiddleware(http.HandlerFunc(c.licenseHandler))))) mux.Handle("/api/license/{action}", c.authMiddleware(c.injectUserMiddleware(c.isAdminMiddleware(http.HandlerFunc(c.licenseHandler)))))