Add getPrefixes to get string array of PathPrefixes

Marathon label traefik.prefixes can be used to specify what
prefixes to use.

New example marathon-prefix.tmpl to take advantage of this new
mechanism.
This commit is contained in:
Thorhallur Sverrisson 2015-09-22 08:23:27 +00:00
parent cae02b02ac
commit bc94ace7d3
3 changed files with 36 additions and 0 deletions

View file

@ -53,6 +53,14 @@ var MarathonFuncMap = template.FuncMap{
}
return "0"
},
"getPrefixes": func(application marathon.Application) ([]string, error) {
for key, value := range application.Labels {
if key == "traefik.prefixes" {
return strings.Split(value, ","), nil
}
}
return []string{}, nil
},
"replace": func(s1 string, s2 string, s3 string) string {
return strings.Replace(s3, s1, s2, -1)
},