Trying to add _ls and _tree subcalls to item paths..

This commit is contained in:
Kalzu Rekku
2025-09-29 21:14:03 +03:00
parent 32b347f1fd
commit d5a0eb7efe
5 changed files with 387 additions and 59 deletions

View File

@@ -52,6 +52,27 @@ func (s *Server) setupRoutes() *mux.Router {
)(s.updateResourceMetadataHandler)).Methods("PUT")
}
// Key listing endpoints (read-only, leverage Merkle tree)
if s.config.ClusteringEnabled { // Require Merkle for efficiency
// _ls endpoint - require read if auth enabled and not anonymous
if s.config.AuthEnabled && !s.config.AllowAnonymousRead {
router.Handle("/kv/{path:.+}/_ls", s.authService.Middleware(
[]string{"read"}, nil, "",
)(s.getKeyListHandler)).Methods("GET")
} else {
router.HandleFunc("/kv/{path:.+}/_ls", s.getKeyListHandler).Methods("GET")
}
// _tree endpoint - same auth rules
if s.config.AuthEnabled && !s.config.AllowAnonymousRead {
router.Handle("/kv/{path:.+}/_tree", s.authService.Middleware(
[]string{"read"}, nil, "",
)(s.getKeyTreeHandler)).Methods("GET")
} else {
router.HandleFunc("/kv/{path:.+}/_tree", s.getKeyTreeHandler).Methods("GET")
}
}
// Member endpoints (available when clustering is enabled)
if s.config.ClusteringEnabled {
router.HandleFunc("/members/", s.getMembersHandler).Methods("GET")