forked from solo-io/gloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
50 lines (46 loc) · 1.03 KB
/
routes.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
package helpers
import (
gatwayv1 "github.com/solo-io/gloo/projects/gateway/pkg/api/v1"
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
)
const (
ExactPath = iota
PrefixPath
RegexPath
)
func MakeRoute(pathType int, length int) *v1.Route {
pathStr := "/"
for i := 0; i < length; i++ {
pathStr += "s/"
}
m := &v1.Matcher{}
switch pathType {
case ExactPath:
m.PathSpecifier = &v1.Matcher_Exact{pathStr}
case PrefixPath:
m.PathSpecifier = &v1.Matcher_Prefix{pathStr}
case RegexPath:
m.PathSpecifier = &v1.Matcher_Regex{pathStr}
default:
panic("bad test")
}
return &v1.Route{Matcher: m}
}
func MakeGatewayRoute(pathType int, length int) *gatwayv1.Route {
pathStr := "/"
for i := 0; i < length; i++ {
pathStr += "s/"
}
m := &v1.Matcher{}
switch pathType {
case ExactPath:
m.PathSpecifier = &v1.Matcher_Exact{pathStr}
case PrefixPath:
m.PathSpecifier = &v1.Matcher_Prefix{pathStr}
case RegexPath:
m.PathSpecifier = &v1.Matcher_Regex{pathStr}
default:
panic("bad test")
}
return &gatwayv1.Route{Matcher: m}
}