-
Notifications
You must be signed in to change notification settings - Fork 204
/
matchers.go
79 lines (73 loc) · 2.02 KB
/
matchers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package matchers
type MatcherFunc func(data interface{}, toMatch string) bool
type MatcherFuncWithConfig func(data interface{}, toMatch string, config map[string]interface{}) bool
/*
this is called only if matcher returns true and there is chaining to feed value
this is set as nil for matchers where we are doing complete details match and there is no need of chaining
*/
type MatcherValueGenerator func(data interface{}, toMatch string) string
var Matchers = map[string]MatcherDetails{
// Default matcher
"": {
MatcherFunction: ExactMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Exact: {
MatcherFunction: ExactMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Glob: {
MatcherFunction: GlobMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Json: {
MatcherFunction: JsonMatch,
MatchValueGenerator: IdentityValueGenerator,
},
JsonPath: {
MatcherFunction: JsonPathMatch,
MatchValueGenerator: JsonPathMatcherValueGenerator,
},
JsonPartial: {
MatcherFunction: JsonPartialMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Regex: {
MatcherFunction: RegexMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Xml: {
MatcherFunction: XmlMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Xpath: {
MatcherFunction: XpathMatch,
MatchValueGenerator: XPathMatchValueGenerator,
},
XmlTemplated: {
MatcherFunction: XmlTemplatedMatch,
MatchValueGenerator: IdentityValueGenerator,
},
Array: {
MatcherFunction: ArrayMatchWithoutConfig,
MatchValueGenerator: IdentityValueGenerator,
},
JWT: {
MatcherFunction: JwtMatcher,
MatchValueGenerator: JwtMatchValueGenerator,
},
Negation: {
MatcherFunction: NegationMatch,
MatchValueGenerator: IdentityValueGenerator,
},
}
type MatcherDetails struct {
MatcherFunction interface{}
MatchValueGenerator MatcherValueGenerator
}
var MatchersWithConfig = map[string]MatcherDetails{
Array: {
MatcherFunction: ArrayMatch,
MatchValueGenerator: IdentityValueGenerator,
},
}