-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
56 lines (45 loc) · 831 Bytes
/
data.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
package baker
import (
"encoding/json"
"net/netip"
"strings"
)
type Meta struct {
Static struct {
Domain string
Path string
Headers map[string]string
}
}
type Container struct {
Id string
ConfigPath string
Addr netip.AddrPort
Meta Meta
}
type Endpoint struct {
Domain string `json:"domain"`
Path string `json:"path"`
Rules []Rule `json:"rules"`
}
func (e *Endpoint) getHashKey() string {
var sb strings.Builder
sb.WriteString(e.Domain)
sb.WriteString(e.Path)
return sb.String()
}
type Rule struct {
Type string `json:"type"`
Args json.RawMessage `json:"args"`
}
type Config struct {
Endpoints []Endpoint `json:"endpoints"`
}
type Service struct {
Containers []*Container
Endpoint *Endpoint
}
type Driver interface {
Add(*Container)
Remove(*Container)
}