1
0
Fork 0

Redirection: permanent move option.

This commit is contained in:
Ludovic Fernandez 2018-01-31 19:10:04 +01:00 committed by Traefiker
parent c944d203fb
commit 58d6681824
83 changed files with 622 additions and 8611 deletions

View file

@ -312,9 +312,12 @@ func (p *Provider) getBuffering(tags []string) *types.Buffering {
}
func (p *Provider) getRedirect(tags []string) *types.Redirect {
permanent := p.getBoolAttribute(label.SuffixFrontendRedirectPermanent, tags, false)
if p.hasAttribute(label.SuffixFrontendRedirectEntryPoint, tags) {
return &types.Redirect{
EntryPoint: p.getAttribute(label.SuffixFrontendRedirectEntryPoint, tags, ""),
Permanent: permanent,
}
}
@ -322,6 +325,7 @@ func (p *Provider) getRedirect(tags []string) *types.Redirect {
return &types.Redirect{
Regex: p.getAttribute(label.SuffixFrontendRedirectRegex, tags, ""),
Replacement: p.getAttribute(label.SuffixFrontendRedirectReplacement, tags, ""),
Permanent: permanent,
}
}

View file

@ -1083,6 +1083,17 @@ func TestProviderGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect tags (permanent)",
tags: []string{
label.TraefikFrontendRedirectEntryPoint + "=https",
label.TraefikFrontendRedirectPermanent + "=true",
},
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect tags",
tags: []string{
@ -1094,6 +1105,19 @@ func TestProviderGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect tags (permanent)",
tags: []string{
label.TraefikFrontendRedirectRegex + "=(.*)",
label.TraefikFrontendRedirectReplacement + "=$1",
label.TraefikFrontendRedirectPermanent + "=true",
},
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {