1
0
Fork 0

feat(kv): add frontend redirect configuration.

This commit is contained in:
Fernandez Ludovic 2018-01-03 16:37:31 +01:00 committed by Traefiker
parent 40b59da224
commit cfa1f47226
4 changed files with 99 additions and 0 deletions

View file

@ -33,6 +33,8 @@ func (p *Provider) buildConfiguration() *types.Configuration {
"Last": p.last,
"Has": p.has,
// Frontend functions
"getRedirect": p.getRedirect,
// Backend functions
"getSticky": p.getSticky,
"hasStickinessLabel": p.hasStickinessLabel,
@ -77,6 +79,23 @@ func (p *Provider) getStickinessCookieName(rootPath string) string {
return p.get("", rootPath, pathBackendLoadBalancerStickinessCookieName)
}
func (p *Provider) getRedirect(rootPath string) *types.Redirect {
if p.has(rootPath, pathFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: p.get("", rootPath, pathFrontendRedirectEntryPoint),
}
}
if p.has(rootPath, pathFrontendRedirectRegex) && p.has(rootPath, pathFrontendRedirectReplacement) {
return &types.Redirect{
Regex: p.get("", rootPath, pathFrontendRedirectRegex),
Replacement: p.get("", rootPath, pathFrontendRedirectReplacement),
}
}
return nil
}
func (p *Provider) listServers(backend string) []string {
serverNames := p.list(backend, pathBackendServers)
return fun.Filter(p.serverFilter, serverNames).([]string)