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

Method getAndStoreMatcherExpression

enforcer.go:909–924  ·  view source on GitHub ↗
(hasEval bool, expString string, functions map[string]govaluate.ExpressionFunction)

Source from the content-addressed store, hash-verified

907}
908
909func (e *Enforcer) getAndStoreMatcherExpression(hasEval bool, expString string, functions map[string]govaluate.ExpressionFunction) (*govaluate.EvaluableExpression, error) {
910 var expression *govaluate.EvaluableExpression
911 var err error
912 var cachedExpression, isPresent = e.matcherMap.Load(expString)
913
914 if !hasEval && isPresent {
915 expression = cachedExpression.(*govaluate.EvaluableExpression)
916 } else {
917 expression, err = govaluate.NewEvaluableExpressionWithFunctions(expString, functions)
918 if err != nil {
919 return nil, err
920 }
921 e.matcherMap.Store(expString, expression)
922 }
923 return expression, nil
924}
925
926// Enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
927func (e *Enforcer) Enforce(rvals ...interface{}) (bool, error) {

Callers 1

enforceMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected