Skip to content

Commit

Permalink
iterate over every app to get router
Browse files Browse the repository at this point in the history
  • Loading branch information
wardviaene committed Oct 15, 2024
1 parent f9a48d0 commit 112e507
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions rest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)))))
Expand Down

0 comments on commit 112e507

Please sign in to comment.