MCPcopy Create free account
hub / github.com/cloudwan/gohan / canUseAction

Function canUseAction

cli/template.go:353–360  ·  view source on GitHub ↗
(action schema.Action, policies []*schema.Policy, url string)

Source from the content-addressed store, hash-verified

351}
352
353func canUseAction(action schema.Action, policies []*schema.Policy, url string) bool {
354 for _, policy := range policies {
355 if policy.GetResourcePathRegexp().MatchString(url) && isMatchingPolicy(action, policy) {
356 return true
357 }
358 }
359 return false
360}
361
362func isMatchingPolicy(action schema.Action, policy *schema.Policy) bool {
363 return action.ID == policy.Action || policy.Action == "*" || (policy.Action == "read" && action.Method == "GET") || (policy.Action == "update" && action.Method == "POST")

Callers 1

filterActionsFunction · 0.85

Calls 2

isMatchingPolicyFunction · 0.85
GetResourcePathRegexpMethod · 0.80

Tested by

no test coverage detected