Custom frontend name for test helper

This commit is contained in:
Ludovic Fernandez 2018-06-06 15:20:03 +02:00 committed by Traefiker Bot
parent 2c47691cf1
commit e9c63f3988
2 changed files with 25 additions and 0 deletions

View file

@ -180,11 +180,22 @@ func frontend(backend string, opts ...func(*types.Frontend)) func(*types.Fronten
for _, opt := range opts {
opt(f)
}
// related the function frontendName
name := f.Backend
f.Backend = backend
if len(name) > 0 {
return name
}
return backend
}
}
func frontendName(name string) func(*types.Frontend) {
return func(f *types.Frontend) {
// store temporary the frontend name into the backend name
f.Backend = name
}
}
func passHostHeader() func(*types.Frontend) {
return func(f *types.Frontend) {
f.PassHostHeader = true

View file

@ -91,11 +91,25 @@ func WithFrontend(backend string, opts ...func(*types.Frontend)) func(*types.Fro
for _, opt := range opts {
opt(f)
}
// related the function WithFrontendName
name := f.Backend
f.Backend = backend
if len(name) > 0 {
return name
}
return backend
}
}
// WithFrontendName is a helper to create a configuration
func WithFrontendName(name string) func(*types.Frontend) {
return func(f *types.Frontend) {
// store temporary the frontend name into the backend name
f.Backend = name
}
}
// WithEntryPoints is a helper to create a configuration
func WithEntryPoints(eps ...string) func(*types.Frontend) {
return func(f *types.Frontend) {