-
Notifications
You must be signed in to change notification settings - Fork 34
/
rewrite_operators.go
97 lines (92 loc) · 2.58 KB
/
rewrite_operators.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package teaconfigs
import "github.com/iwind/TeaGo/maps"
// 运算符定义
type RequestCondOperator = string
const (
RequestCondOperatorRegexp = "regexp"
RequestCondOperatorNotRegexp = "not regexp"
RequestCondOperatorGt = "gt"
RequestCondOperatorGte = "gte"
RequestCondOperatorLt = "lt"
RequestCondOperatorLte = "lte"
RequestCondOperatorEq = "eq"
RequestCondOperatorNot = "not"
RequestCondOperatorPrefix = "prefix"
RequestCondOperatorSuffix = "suffix"
RequestCondOperatorContains = "contains"
RequestCondOperatorNotContains = "not contains"
)
// 所有的运算符
func AllRequestOperators() []maps.Map {
return []maps.Map{
{
"name": "正则表达式匹配",
"op": RequestCondOperatorRegexp,
"description": "判断是否正则表达式匹配",
},
{
"name": "正则表达式不匹配",
"op": RequestCondOperatorNotRegexp,
"description": "判断是否正则表达式不匹配",
},
{
"name": "等于",
"op": RequestCondOperatorEq,
"description": "使用字符串对比参数值是否相等于某个值",
},
{
"name": "前缀",
"op": RequestCondOperatorPrefix,
"description": "参数值包含某个前缀",
},
{
"name": "后缀",
"op": RequestCondOperatorSuffix,
"description": "参数值包含某个后缀",
},
{
"name": "包含",
"op": RequestCondOperatorContains,
"description": "参数值包含另外一个字符串",
},
{
"name": "不包含",
"op": RequestCondOperatorNotContains,
"description": "参数值不包含另外一个字符串",
},
{
"name": "不等于",
"op": RequestCondOperatorNot,
"description": "使用字符串对比参数值是否不相等于某个值",
},
{
"name": "大于",
"op": RequestCondOperatorGt,
"description": "将参数转换为数字进行对比",
},
{
"name": "大于等于",
"op": RequestCondOperatorGte,
"description": "将参数转换为数字进行对比",
},
{
"name": "小于",
"op": RequestCondOperatorLt,
"description": "将参数转换为数字进行对比",
},
{
"name": "小于等于",
"op": RequestCondOperatorLte,
"description": "将参数转换为数字进行对比",
},
}
}
// 查找某个运算符信息
func FindRequestCondOperator(op string) maps.Map {
for _, o := range AllRequestOperators() {
if o["op"] == op {
return o
}
}
return nil
}