github.com/Axway/agent-sdk@v1.1.101/pkg/traceability/apiExceptionList.go (about) 1 package traceability 2 3 import ( 4 "regexp" 5 "strings" 6 7 "github.com/Axway/agent-sdk/pkg/util/log" 8 ) 9 10 // setUpAPIExceptionList - called from config to set up api exceptions list for traceability 11 func setUpAPIExceptionList(cfgAPIiExceptionsList []string) (string, error) { 12 // if set check for valid regex definitions 13 exceptionRegEx = make([]*regexp.Regexp, 0) 14 15 // Get the api exceptions list 16 exceptions := cfgAPIiExceptionsList 17 for i := range exceptions { 18 exception := strings.TrimSpace(exceptions[i]) 19 20 // check for regex and then validate 21 keyMatch, err := regexp.Compile(exception) 22 if err != nil { 23 return exception, err 24 } 25 26 exceptionRegEx = append(exceptionRegEx, keyMatch) 27 28 } 29 30 return "", nil 31 } 32 33 // exceptionRegEx - array of regexp.Regexp 34 var exceptionRegEx []*regexp.Regexp 35 36 // ShouldIgnoreEvent - check to see if the uri exists in exception list 37 func ShouldIgnoreEvent(uriRaw string) bool { 38 39 // If the api path exists in the exceptions list, return true and ignore event 40 for _, exception := range exceptionRegEx { 41 if exception.MatchString(uriRaw) { 42 log.Debugf("%s found in exception list. Do not process event.", uriRaw) 43 return true 44 } 45 } 46 47 // api path not found in exceptions list 48 return false 49 }