grim/hgkeeper

ae75fb1d8de7
Put the docs in a zip file when generating them
package access
import (
"path/filepath"
"sync"
"github.com/casbin/casbin/v2"
"go.uber.org/zap"
)
var (
enforcer *casbin.Enforcer
enforcerLock sync.Mutex
)
func refreshEnforcer() error {
enforcerLock.Lock()
defer enforcerLock.Unlock()
modelFile := filepath.Join(AdminRepoPath(), modelFilename)
policyFile := filepath.Join(AdminRepoPath(), policyFilename)
zap.S().Debugf("reading model from %q", modelFile)
zap.S().Debugf("reading policy from %q", policyFile)
e, err := casbin.NewEnforcer(modelFile, policyFile)
if err != nil {
zap.S().Errorf("failed to create new enforcer: %v", err)
return err
}
enforcer = e
return nil
}