toml config with nested tables
This commit is contained in:
parent
c460f3abcd
commit
b5828f89e2
2 changed files with 22 additions and 24 deletions
15
tortuous.go
15
tortuous.go
|
@ -16,12 +16,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
Name string
|
|
||||||
Servers []string
|
Servers []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Name string
|
|
||||||
Url string
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,14 +29,14 @@ type Rule struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Route struct {
|
type Route struct {
|
||||||
Name string
|
Backends []string
|
||||||
Rules map[string]Rule
|
Rules map[string]Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Backends []Backend
|
Backends map[string]Backend
|
||||||
Servers []Server
|
Servers map[string]Server
|
||||||
Routes []Route
|
Routes map[string]Route
|
||||||
}
|
}
|
||||||
|
|
||||||
var srv *graceful.Server
|
var srv *graceful.Server
|
||||||
|
@ -60,7 +58,11 @@ func main() {
|
||||||
systemRouter.Methods("GET").Path("/").HandlerFunc(GetPidHandler)
|
systemRouter.Methods("GET").Path("/").HandlerFunc(GetPidHandler)
|
||||||
go http.ListenAndServe(":8000", systemRouter)
|
go http.ListenAndServe(":8000", systemRouter)
|
||||||
|
|
||||||
|
userRouter := mux.NewRouter()
|
||||||
|
|
||||||
|
/*for i := range config.Routes {
|
||||||
|
fmt.Printf("%+v\n", config.Routes[i] )
|
||||||
|
}*/
|
||||||
|
|
||||||
fwd, _ := forward.New()
|
fwd, _ := forward.New()
|
||||||
lb, _ := roundrobin.New(fwd)
|
lb, _ := roundrobin.New(fwd)
|
||||||
|
@ -68,7 +70,6 @@ func main() {
|
||||||
lb.UpsertServer(testutils.ParseURI("http://172.17.0.2:80"))
|
lb.UpsertServer(testutils.ParseURI("http://172.17.0.2:80"))
|
||||||
lb.UpsertServer(testutils.ParseURI("http://172.17.0.3:80"))
|
lb.UpsertServer(testutils.ParseURI("http://172.17.0.3:80"))
|
||||||
|
|
||||||
userRouter := mux.NewRouter()
|
|
||||||
userRouter.Host("test.zenika.fr").Handler(lb)
|
userRouter.Host("test.zenika.fr").Handler(lb)
|
||||||
|
|
||||||
goAway := false
|
goAway := false
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
[[backends]]
|
[backends]
|
||||||
name = "backend1"
|
[backends.backend1]
|
||||||
servers = ["server1", "server2"]
|
servers = ["server1", "server2"]
|
||||||
|
|
||||||
[[servers]]
|
[servers]
|
||||||
name = "server1"
|
[servers.server1]
|
||||||
url = "http://172.17.0.2:80"
|
url = "http://172.17.0.2:80"
|
||||||
|
[servers.server2]
|
||||||
|
url = "http://172.17.0.3:80"
|
||||||
|
|
||||||
[[servers]]
|
[routes]
|
||||||
name = "server2"
|
[routes.route1]
|
||||||
url = "http://172.17.0.3:80"
|
backends = ["backend1"]
|
||||||
|
[routes.route1.rules.test_zenika]
|
||||||
[[routes]]
|
category = "Host"
|
||||||
name = "route1"
|
value = "test.zenika.fr"
|
||||||
backends = ["backend1"]
|
|
||||||
[[rules]]
|
|
||||||
[[rules.1]]
|
|
||||||
category = "Host"
|
|
||||||
value = "test.zenika.fr"
|
|
||||||
|
|
Loading…
Reference in a new issue