-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_type.go
More file actions
54 lines (45 loc) · 1.59 KB
/
config_type.go
File metadata and controls
54 lines (45 loc) · 1.59 KB
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
package sentinel
type Config struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Backends []Backend `json:"backends" yaml:"backends"`
}
type Backend struct {
Patterns []Pattern `json:"patterns" yaml:"patterns"`
Methods []Method `json:"methods" yaml:"methods"`
LoadBalancer LoadBalancerAlgorithm `json:"load_balancer" yaml:"load_balancer"`
Services []Service `json:"services" yaml:"services"`
Middlewares []Middleware `json:"middlewares" yaml:"middlewares"`
}
type Pattern struct {
From string `json:"from" yaml:"from"`
To string `json:"to" yaml:"to"`
}
type Method string
const (
MethodGet Method = "GET"
MethodHead Method = "HEAD"
MethodPost Method = "POST"
MethodPut Method = "PUT"
MethodPatch Method = "PATCH"
MethodDelete Method = "DELETE"
MethodConnect Method = "CONNECT"
MethodOptions Method = "OPTIONS"
MethodTrace Method = "TRACE"
)
type LoadBalancerAlgorithm string
const (
LoadBalancerAlgorithmRoundRobin LoadBalancerAlgorithm = "round-robin"
LoadBalancerAlgorithmRandom LoadBalancerAlgorithm = "random"
LoadBalancerAlgorithmLeastConn LoadBalancerAlgorithm = "least-connections"
LoadBalancerAlgorithmIPHash LoadBalancerAlgorithm = "ip-hash"
LoadBalancerAlgorithmWeighted LoadBalancerAlgorithm = "weighted"
)
type Service struct {
Url string `json:"url" yaml:"url"`
Weight int `json:"weight" yaml:"weight"`
}
type Middleware struct {
Name string `json:"name" yaml:"name"`
Config map[string]any `json:"config" yaml:"config"`
}