Skip to content

Commit

Permalink
fixed #16
Browse files Browse the repository at this point in the history
  • Loading branch information
mikespook committed Apr 6, 2017
1 parent 2f7408d commit d83d2ac
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions helper.go
Expand Up @@ -2,18 +2,21 @@ package gorbac

import "fmt"

// RoleHandler is a function defined by user to handle role
// WalkHandler is a function defined by user to handle role
type WalkHandler func(Role, []string) error

// Walk passes each Role to PersistenceHandler
// Walk passes each Role to WalkHandler
func Walk(rbac *RBAC, h WalkHandler) (err error) {
if h == nil {
return
}
rbac.mutex.Lock()
defer rbac.mutex.Unlock()
for id := range rbac.roles {
r, parents, err := rbac.Get(id)
if err != nil {
return err
var parents []string
r := rbac.roles[id]
for parent := range rbac.parents[id] {
parents = append(parents, parent)
}
if err := h(r, parents); err != nil {
return err
Expand Down

0 comments on commit d83d2ac

Please sign in to comment.