@@ -20,7 +20,7 @@ func TestEngineMatches(t *testing.T) {
20
20
{
21
21
name : "method matches exact" ,
22
22
rule : Rule {
23
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "GET" ) : {}},
23
+ MethodPatterns : map [string ]struct {}{"GET" : {}},
24
24
},
25
25
method : "GET" ,
26
26
url : "https://example.com/api" ,
@@ -29,7 +29,7 @@ func TestEngineMatches(t *testing.T) {
29
29
{
30
30
name : "method does not match" ,
31
31
rule : Rule {
32
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "POST" ) : {}},
32
+ MethodPatterns : map [string ]struct {}{"POST" : {}},
33
33
},
34
34
method : "GET" ,
35
35
url : "https://example.com/api" ,
@@ -38,7 +38,7 @@ func TestEngineMatches(t *testing.T) {
38
38
{
39
39
name : "method wildcard matches any" ,
40
40
rule : Rule {
41
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "*" ) : {}},
41
+ MethodPatterns : map [string ]struct {}{"*" : {}},
42
42
},
43
43
method : "PUT" ,
44
44
url : "https://example.com/api" ,
@@ -47,7 +47,7 @@ func TestEngineMatches(t *testing.T) {
47
47
{
48
48
name : "no method pattern allows all methods" ,
49
49
rule : Rule {
50
- HostPattern : []labelPattern { labelPattern ( "example" ), labelPattern ( "com" ) },
50
+ HostPattern : []string { "example" , "com" },
51
51
},
52
52
method : "DELETE" ,
53
53
url : "https://example.com/api" ,
@@ -58,7 +58,7 @@ func TestEngineMatches(t *testing.T) {
58
58
{
59
59
name : "host matches exact" ,
60
60
rule : Rule {
61
- HostPattern : []labelPattern { labelPattern ( "example" ), labelPattern ( "com" ) },
61
+ HostPattern : []string { "example" , "com" },
62
62
},
63
63
method : "GET" ,
64
64
url : "https://example.com/api" ,
@@ -67,7 +67,7 @@ func TestEngineMatches(t *testing.T) {
67
67
{
68
68
name : "host does not match" ,
69
69
rule : Rule {
70
- HostPattern : []labelPattern { labelPattern ( "example" ), labelPattern ( "org" ) },
70
+ HostPattern : []string { "example" , "org" },
71
71
},
72
72
method : "GET" ,
73
73
url : "https://example.com/api" ,
@@ -76,7 +76,7 @@ func TestEngineMatches(t *testing.T) {
76
76
{
77
77
name : "subdomain matches" ,
78
78
rule : Rule {
79
- HostPattern : []labelPattern { labelPattern ( "example" ), labelPattern ( "com" ) },
79
+ HostPattern : []string { "example" , "com" },
80
80
},
81
81
method : "GET" ,
82
82
url : "https://api.example.com/users" ,
@@ -85,7 +85,7 @@ func TestEngineMatches(t *testing.T) {
85
85
{
86
86
name : "host pattern too long" ,
87
87
rule : Rule {
88
- HostPattern : []labelPattern { labelPattern ( "v1" ), labelPattern ( "api" ), labelPattern ( "example" ), labelPattern ( "com" ) },
88
+ HostPattern : []string { "v1" , "api" , "example" , "com" },
89
89
},
90
90
method : "GET" ,
91
91
url : "https://api.example.com/users" ,
@@ -94,7 +94,7 @@ func TestEngineMatches(t *testing.T) {
94
94
{
95
95
name : "host wildcard matches" ,
96
96
rule : Rule {
97
- HostPattern : []labelPattern { labelPattern ( "*" ), labelPattern ( "com" ) },
97
+ HostPattern : []string { "*" , "com" },
98
98
},
99
99
method : "GET" ,
100
100
url : "https://test.com/api" ,
@@ -103,7 +103,7 @@ func TestEngineMatches(t *testing.T) {
103
103
{
104
104
name : "multiple host wildcards" ,
105
105
rule : Rule {
106
- HostPattern : []labelPattern { labelPattern ( "*" ), labelPattern ( "*" ) },
106
+ HostPattern : []string { "*" , "*" },
107
107
},
108
108
method : "GET" ,
109
109
url : "https://api.example.com/users" ,
@@ -114,7 +114,7 @@ func TestEngineMatches(t *testing.T) {
114
114
{
115
115
name : "path matches exact" ,
116
116
rule : Rule {
117
- PathPattern : []segmentPattern { segmentPattern ( "api" ), segmentPattern ( "users" ) },
117
+ PathPattern : []string { "api" , "users" },
118
118
},
119
119
method : "GET" ,
120
120
url : "https://example.com/api/users" ,
@@ -123,7 +123,7 @@ func TestEngineMatches(t *testing.T) {
123
123
{
124
124
name : "path does not match" ,
125
125
rule : Rule {
126
- PathPattern : []segmentPattern { segmentPattern ( "api" ), segmentPattern ( "posts" ) },
126
+ PathPattern : []string { "api" , "posts" },
127
127
},
128
128
method : "GET" ,
129
129
url : "https://example.com/api/users" ,
@@ -132,7 +132,7 @@ func TestEngineMatches(t *testing.T) {
132
132
{
133
133
name : "subpath matches" ,
134
134
rule : Rule {
135
- PathPattern : []segmentPattern { segmentPattern ( "api" ) },
135
+ PathPattern : []string { "api" },
136
136
},
137
137
method : "GET" ,
138
138
url : "https://example.com/api/users/123" ,
@@ -141,7 +141,7 @@ func TestEngineMatches(t *testing.T) {
141
141
{
142
142
name : "path pattern too long" ,
143
143
rule : Rule {
144
- PathPattern : []segmentPattern { segmentPattern ( "api" ), segmentPattern ( "v1" ), segmentPattern ( "users" ), segmentPattern ( "profile" ) },
144
+ PathPattern : []string { "api" , "v1" , "users" , "profile" },
145
145
},
146
146
method : "GET" ,
147
147
url : "https://example.com/api/v1/users" ,
@@ -150,7 +150,7 @@ func TestEngineMatches(t *testing.T) {
150
150
{
151
151
name : "path wildcard matches" ,
152
152
rule : Rule {
153
- PathPattern : []segmentPattern { segmentPattern ( "api" ), segmentPattern ( "*" ), segmentPattern ( "profile" ) },
153
+ PathPattern : []string { "api" , "*" , "profile" },
154
154
},
155
155
method : "GET" ,
156
156
url : "https://example.com/api/users/profile" ,
@@ -159,7 +159,7 @@ func TestEngineMatches(t *testing.T) {
159
159
{
160
160
name : "multiple path wildcards" ,
161
161
rule : Rule {
162
- PathPattern : []segmentPattern { segmentPattern ( "*" ), segmentPattern ( "*" ) },
162
+ PathPattern : []string { "*" , "*" },
163
163
},
164
164
method : "GET" ,
165
165
url : "https://example.com/api/users/123" ,
@@ -170,9 +170,9 @@ func TestEngineMatches(t *testing.T) {
170
170
{
171
171
name : "all patterns match" ,
172
172
rule : Rule {
173
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "POST" ) : {}},
174
- HostPattern : []labelPattern { labelPattern ( "api" ), labelPattern ( "com" ) },
175
- PathPattern : []segmentPattern { segmentPattern ( "users" ) },
173
+ MethodPatterns : map [string ]struct {}{"POST" : {}},
174
+ HostPattern : []string { "api" , "com" },
175
+ PathPattern : []string { "users" },
176
176
},
177
177
method : "POST" ,
178
178
url : "https://api.com/users" ,
@@ -181,9 +181,9 @@ func TestEngineMatches(t *testing.T) {
181
181
{
182
182
name : "method fails combined test" ,
183
183
rule : Rule {
184
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "POST" ) : {}},
185
- HostPattern : []labelPattern { labelPattern ( "api" ), labelPattern ( "com" ) },
186
- PathPattern : []segmentPattern { segmentPattern ( "users" ) },
184
+ MethodPatterns : map [string ]struct {}{"POST" : {}},
185
+ HostPattern : []string { "api" , "com" },
186
+ PathPattern : []string { "users" },
187
187
},
188
188
method : "GET" ,
189
189
url : "https://api.com/users" ,
@@ -192,9 +192,9 @@ func TestEngineMatches(t *testing.T) {
192
192
{
193
193
name : "host fails combined test" ,
194
194
rule : Rule {
195
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "POST" ) : {}},
196
- HostPattern : []labelPattern { labelPattern ( "api" ), labelPattern ( "org" ) },
197
- PathPattern : []segmentPattern { segmentPattern ( "users" ) },
195
+ MethodPatterns : map [string ]struct {}{"POST" : {}},
196
+ HostPattern : []string { "api" , "org" },
197
+ PathPattern : []string { "users" },
198
198
},
199
199
method : "POST" ,
200
200
url : "https://api.com/users" ,
@@ -203,9 +203,9 @@ func TestEngineMatches(t *testing.T) {
203
203
{
204
204
name : "path fails combined test" ,
205
205
rule : Rule {
206
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "POST" ) : {}},
207
- HostPattern : []labelPattern { labelPattern ( "api" ), labelPattern ( "com" ) },
208
- PathPattern : []segmentPattern { segmentPattern ( "posts" ) },
206
+ MethodPatterns : map [string ]struct {}{"POST" : {}},
207
+ HostPattern : []string { "api" , "com" },
208
+ PathPattern : []string { "posts" },
209
209
},
210
210
method : "POST" ,
211
211
url : "https://api.com/users" ,
@@ -214,9 +214,9 @@ func TestEngineMatches(t *testing.T) {
214
214
{
215
215
name : "all wildcards match" ,
216
216
rule : Rule {
217
- MethodPatterns : map [methodPattern ]struct {}{methodPattern ( "*" ) : {}},
218
- HostPattern : []labelPattern { labelPattern ( "*" ), labelPattern ( "*" ) },
219
- PathPattern : []segmentPattern { segmentPattern ( "*" ), segmentPattern ( "*" ) },
217
+ MethodPatterns : map [string ]struct {}{"*" : {}},
218
+ HostPattern : []string { "*" , "*" },
219
+ PathPattern : []string { "*" , "*" },
220
220
},
221
221
method : "PATCH" ,
222
222
url : "https://test.example.com/api/users/123" ,
@@ -234,7 +234,7 @@ func TestEngineMatches(t *testing.T) {
234
234
{
235
235
name : "invalid URL" ,
236
236
rule : Rule {
237
- HostPattern : []labelPattern { labelPattern ( "example" ), labelPattern ( "com" ) },
237
+ HostPattern : []string { "example" , "com" },
238
238
},
239
239
method : "GET" ,
240
240
url : "not-a-valid-url" ,
@@ -243,7 +243,7 @@ func TestEngineMatches(t *testing.T) {
243
243
{
244
244
name : "root path" ,
245
245
rule : Rule {
246
- PathPattern : []segmentPattern {},
246
+ PathPattern : []string {},
247
247
},
248
248
method : "GET" ,
249
249
url : "https://example.com/" ,
@@ -252,7 +252,7 @@ func TestEngineMatches(t *testing.T) {
252
252
{
253
253
name : "localhost host" ,
254
254
rule : Rule {
255
- HostPattern : []labelPattern { labelPattern ( "localhost" ) },
255
+ HostPattern : []string { "localhost" },
256
256
},
257
257
method : "GET" ,
258
258
url : "http://localhost:8080/api" ,
0 commit comments