From ef9e773b9fcaaf18b4adf29afd8252aaf5fa8a96 Mon Sep 17 00:00:00 2001 From: emile Date: Tue, 15 Sep 2015 18:35:32 +0200 Subject: [PATCH] refactor rules, api enhancements --- configuration.go | 2 +- providerTemplates/docker.tmpl | 2 +- providerTemplates/marathon.tmpl | 2 +- templates/configuration.tmpl | 4 ++-- traefik.go | 2 +- traefik.sample.toml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/configuration.go b/configuration.go index 4443a2508..e89755e60 100644 --- a/configuration.go +++ b/configuration.go @@ -35,7 +35,7 @@ type Server struct { } type Route struct { - Category string + Rule string Value string } diff --git a/providerTemplates/docker.tmpl b/providerTemplates/docker.tmpl index bbc0be8fe..99c439107 100644 --- a/providerTemplates/docker.tmpl +++ b/providerTemplates/docker.tmpl @@ -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}} \ No newline at end of file diff --git a/providerTemplates/marathon.tmpl b/providerTemplates/marathon.tmpl index bd70edeab..895d494dc 100644 --- a/providerTemplates/marathon.tmpl +++ b/providerTemplates/marathon.tmpl @@ -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}} \ No newline at end of file diff --git a/templates/configuration.tmpl b/templates/configuration.tmpl index 77f50dec0..ff71ed6d7 100644 --- a/templates/configuration.tmpl +++ b/templates/configuration.tmpl @@ -39,13 +39,13 @@ - + {{range $keyRoutes, $valueRoutes := $valueFrontends.Routes}} - + {{end}} diff --git a/traefik.go b/traefik.go index db4472eac..5fa0b7100 100644 --- a/traefik.go +++ b/traefik.go @@ -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 { diff --git a/traefik.sample.toml b/traefik.sample.toml index fd5766ddb..16adb1603 100644 --- a/traefik.sample.toml +++ b/traefik.sample.toml @@ -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"
RouteCategoryRule Value
{{$keyRoutes}}{{$valueRoutes.Category}}{{$valueRoutes.Rule}} {{$valueRoutes.Value}}