Export /api/core subrouter
@@ -28,6 +28,7 @@ import (
type APId struct {
Authenticator *authentication.Authenticator
HTTPServer *http.Server
+ CoreSubrouter *mux.Router
stopping chan struct{}
running *atomic.Value
@@ -102,7 +103,7 @@ func New(c Config, opts ...Option) (*APId, error) {
registerUnauthenticatedResources(router, a.store, a.cluster, a.etcdClientTLSConfig)
registerGraphQLService(router, a.store, c.URL, tlsClientConfig)
registerAuthenticationResources(router, a.store, a.Authenticator)
- registerRestrictedResources(router, a.store, a.queueGetter, a.bus, a.cluster)
+ a.registerRestrictedResources(router)
a.HTTPServer = &http.Server{
Addr: c.ListenAddress,
@@ -228,38 +229,39 @@ func registerAuthenticationResources(router *mux.Router, store store.Store, auth
)
}
-func registerRestrictedResources(router *mux.Router, store store.Store, getter types.QueueGetter, bus messaging.MessageBus, cluster clientv3.Cluster) {
- mountRouters(
- NewSubrouter(
+func (a *APId) registerRestrictedResources(router *mux.Router) {
+ a.CoreSubrouter = NewSubrouter(
router.NewRoute().
PathPrefix("/api/{group:core}/{version:v2}/"),
middlewares.SimpleLogger{},
middlewares.Namespace{},
middlewares.Authentication{},
- middlewares.AllowList{Store: store},
+ middlewares.AllowList{Store: a.store},
middlewares.AuthorizationAttributes{},
- middlewares.Authorization{Authorizer: &rbac.Authorizer{Store: store}},
+ middlewares.Authorization{Authorizer: &rbac.Authorizer{Store: a.store}},
middlewares.LimitRequest{},
middlewares.Pagination{},
- ),
- routers.NewAssetRouter(store),
- routers.NewChecksRouter(actions.NewCheckController(store, getter)),
- routers.NewClusterRolesRouter(store),
- routers.NewClusterRoleBindingsRouter(store),
- routers.NewClusterRouter(actions.NewClusterController(cluster)),
- routers.NewEntitiesRouter(store),
- routers.NewEventFiltersRouter(store),
- routers.NewEventsRouter(store, bus),
- routers.NewExtensionsRouter(store),
- routers.NewHandlersRouter(store),
- routers.NewHooksRouter(store),
- routers.NewMutatorsRouter(store),
- routers.NewNamespacesRouter(actions.NewNamespacesController(store)),
- routers.NewRolesRouter(store),
- routers.NewRoleBindingsRouter(store),
- routers.NewSilencedRouter(store),
- routers.NewTessenRouter(actions.NewTessenController(store, bus)),
- routers.NewUsersRouter(store),
+ )
+ mountRouters(
+ a.CoreSubrouter,
+ routers.NewAssetRouter(a.store),
+ routers.NewChecksRouter(actions.NewCheckController(a.store, a.queueGetter)),
+ routers.NewClusterRolesRouter(a.store),
+ routers.NewClusterRoleBindingsRouter(a.store),
+ routers.NewClusterRouter(actions.NewClusterController(a.cluster)),
+ routers.NewEntitiesRouter(a.store),
+ routers.NewEventFiltersRouter(a.store),
+ routers.NewEventsRouter(a.store, a.bus),
+ routers.NewExtensionsRouter(a.store),
+ routers.NewHandlersRouter(a.store),
+ routers.NewHooksRouter(a.store),
+ routers.NewMutatorsRouter(a.store),
+ routers.NewNamespacesRouter(actions.NewNamespacesController(a.store)),
+ routers.NewRolesRouter(a.store),
+ routers.NewRoleBindingsRouter(a.store),
+ routers.NewSilencedRouter(a.store),
+ routers.NewTessenRouter(actions.NewTessenController(a.store, a.bus)),
+ routers.NewUsersRouter(a.store),
)
}
