Custom frontend name for test helper
This commit is contained in:
parent
2c47691cf1
commit
e9c63f3988
2 changed files with 25 additions and 0 deletions
|
@ -180,11 +180,22 @@ func frontend(backend string, opts ...func(*types.Frontend)) func(*types.Fronten
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(f)
|
opt(f)
|
||||||
}
|
}
|
||||||
|
// related the function frontendName
|
||||||
|
name := f.Backend
|
||||||
f.Backend = backend
|
f.Backend = backend
|
||||||
|
if len(name) > 0 {
|
||||||
|
return name
|
||||||
|
}
|
||||||
return backend
|
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) {
|
func passHostHeader() func(*types.Frontend) {
|
||||||
return func(f *types.Frontend) {
|
return func(f *types.Frontend) {
|
||||||
f.PassHostHeader = true
|
f.PassHostHeader = true
|
||||||
|
|
|
@ -91,11 +91,25 @@ func WithFrontend(backend string, opts ...func(*types.Frontend)) func(*types.Fro
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(f)
|
opt(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// related the function WithFrontendName
|
||||||
|
name := f.Backend
|
||||||
f.Backend = backend
|
f.Backend = backend
|
||||||
|
if len(name) > 0 {
|
||||||
|
return name
|
||||||
|
}
|
||||||
return backend
|
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
|
// WithEntryPoints is a helper to create a configuration
|
||||||
func WithEntryPoints(eps ...string) func(*types.Frontend) {
|
func WithEntryPoints(eps ...string) func(*types.Frontend) {
|
||||||
return func(f *types.Frontend) {
|
return func(f *types.Frontend) {
|
||||||
|
|
Loading…
Reference in a new issue