implemented api handlers
This commit is contained in:
parent
ab12dd67d4
commit
372915e24d
15 changed files with 302 additions and 73 deletions
|
|
@ -1,29 +1,43 @@
|
|||
package haproxy
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Config struct {
|
||||
LoadBalancers []LoadBalancer
|
||||
LoadBalancers []*LoadBalancer
|
||||
}
|
||||
|
||||
func NewConfig(m map[string][]byte) (c Config, err error) {
|
||||
for _, v := range m {
|
||||
lb := new(LoadBalancer)
|
||||
err = json.Unmarshal(v, lb)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
c.LoadBalancers = append(c.LoadBalancers, lb)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type LoadBalancer struct {
|
||||
Name string
|
||||
IP string
|
||||
Options Options
|
||||
Ports []Port
|
||||
Name string `json:"name"`
|
||||
IP string `json:"ip"`
|
||||
Options Options `json:"options"`
|
||||
Ports []Port `json:"ports"`
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
Frontend []string
|
||||
Backend []string
|
||||
DefaultServer string
|
||||
Frontend []string `json:"frontend"`
|
||||
Backend []string `json:"backend"`
|
||||
DefaultServer string `json:"defaultServer"`
|
||||
}
|
||||
|
||||
type Port struct {
|
||||
Port int
|
||||
Servers []Server
|
||||
Port int `json:"port"`
|
||||
Servers []Server `json:"servers"`
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
Name string
|
||||
IP string
|
||||
Port int
|
||||
Name string `json:"name"`
|
||||
IP string `json:"ip"`
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue