MCPcopy
hub / github.com/apache/casbin / parseRolesArray

Function parseRolesArray

model/constraint.go:55–70  ·  view source on GitHub ↗

parseRolesArray parses a comma-separated string of quoted role names.

(rolesStr string)

Source from the content-addressed store, hash-verified

53
54// parseRolesArray parses a comma-separated string of quoted role names.
55func parseRolesArray(rolesStr string) ([]string, error) {
56 var roles []string
57 for _, role := range strings.Split(rolesStr, ",") {
58 role = strings.TrimSpace(role)
59 role = strings.Trim(role, `"`)
60 if role != "" {
61 roles = append(roles, role)
62 }
63 }
64
65 if len(roles) == 0 {
66 return nil, fmt.Errorf("no roles found in role array")
67 }
68
69 return roles, nil
70}
71
72// parseConstraint parses a constraint definition string.
73func parseConstraint(key, value string) (*Constraint, error) {

Callers 1

parseConstraintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…