diff options
Diffstat (limited to 'internal/api/roles.go')
| -rw-r--r-- | internal/api/roles.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/api/roles.go b/internal/api/roles.go index 700bec4..aa5c807 100644 --- a/internal/api/roles.go +++ b/internal/api/roles.go @@ -25,6 +25,23 @@ type roleVersionView struct { ProposedBy string `json:"proposed_by,omitempty"` } +// handleListRoleNames handles GET /api/roles — every distinct role name +// that has at least one role_configs row. There is no other way to discover +// which roles exist short of guessing names; the role/config management +// panel uses this as its entry point before fetching each role's version +// history via GET /api/roles/{role}/versions. +func (s *Server) handleListRoleNames(w http.ResponseWriter, _ *http.Request) { + names, err := s.store.ListRoleNames() + if err != nil { + writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()}) + return + } + if names == nil { + names = []string{} + } + writeJSON(w, http.StatusOK, names) +} + // handleCreateRoleVersion handles POST /api/roles/{role}/versions. The // request body is a role.RoleConfig (config_json shape, plus an optional // proposed_by field); a new draft version is created with the next version |
