refactor rules, api enhancements

This commit is contained in:
emile 2015-09-15 18:35:32 +02:00
parent a4f542c02f
commit ef9e773b9f
6 changed files with 8 additions and 8 deletions

View file

@ -35,7 +35,7 @@ type Server struct {
}
type Route struct {
Category string
Rule string
Value string
}

View file

@ -9,6 +9,6 @@
{{$container := index $containers 0}}
backend = "backend-{{getBackend $container}}"
[frontends.frontend-{{$host}}.routes.route-host-{{$host}}]
category = "Host"
rule = "Host"
value = "{{$host}}.{{$.Domain}}"
{{end}}

View file

@ -14,6 +14,6 @@
[frontends.frontend{{.ID | replace "/" "-"}}]
backend = "backend{{.ID | replace "/" "-"}}"
[frontends.frontend-{{getHost . | replace "/" "-"}}.routes.route-host-{{getHost . | replace "/" "-"}}]
category = "Host"
rule = "Host"
value = "{{getHost . | replace "/" "-"}}.{{$.Domain}}"
{{end}}

View file

@ -39,13 +39,13 @@
<table class="table table-striped table-hover">
<tr>
<td><em>Route</em></td>
<td><em>Category</em></td>
<td><em>Rule</em></td>
<td><em>Value</em></td>
</tr>
{{range $keyRoutes, $valueRoutes := $valueFrontends.Routes}}
<tr>
<td>{{$keyRoutes}}</td>
<td>{{$valueRoutes.Category}}</td>
<td>{{$valueRoutes.Rule}}</td>
<td>{{$valueRoutes.Value}}</td>
</tr>
{{end}}

View file

@ -188,7 +188,7 @@ func LoadConfig(configuration *Configuration, gloablConfiguration *GlobalConfigu
newRoute := router.NewRoute()
for routeName, route := range frontend.Routes {
log.Debug("Creating route %s", routeName)
newRouteReflect := Invoke(newRoute, route.Category, route.Value)
newRouteReflect := Invoke(newRoute, route.Rule, route.Value)
newRoute = newRouteReflect[0].Interface().(*mux.Route)
}
if backends[frontend.Backend] == nil {

View file

@ -196,10 +196,10 @@
# [frontends.frontend1]
# backend = "backend2"
# [frontends.frontend1.routes.test_1]
# category = "Host"
# rule = "Host"
# value = "test.localhost"
# [frontends.frontend2]
# backend = "backend1"
# [frontends.frontend2.routes.test_2]
# category = "Path"
# rule = "Path"
# value = "/test"