mirror of
https://github.com/traefik/traefik
synced 2026-02-03 11:10:33 +00:00
Merge v2.11 into v3.6
This commit is contained in:
+61
-11
@@ -66,32 +66,75 @@ func WithObservability() func(*dynamic.Router) {
|
||||
}
|
||||
}
|
||||
|
||||
// WithLoadBalancerServices is a helper to create a configuration.
|
||||
func WithLoadBalancerServices(opts ...func(service *dynamic.ServersLoadBalancer) string) func(*dynamic.HTTPConfiguration) {
|
||||
// WithServices is a helper to create a configuration.
|
||||
func WithServices(opts ...func(service *dynamic.Service) string) func(*dynamic.HTTPConfiguration) {
|
||||
return func(c *dynamic.HTTPConfiguration) {
|
||||
c.Services = make(map[string]*dynamic.Service)
|
||||
for _, opt := range opts {
|
||||
b := &dynamic.ServersLoadBalancer{}
|
||||
b.SetDefaults()
|
||||
|
||||
b := &dynamic.Service{}
|
||||
name := opt(b)
|
||||
c.Services[name] = &dynamic.Service{
|
||||
LoadBalancer: b,
|
||||
}
|
||||
c.Services[name] = b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithService is a helper to create a configuration.
|
||||
func WithService(name string, opts ...func(*dynamic.ServersLoadBalancer)) func(*dynamic.ServersLoadBalancer) string {
|
||||
return func(r *dynamic.ServersLoadBalancer) string {
|
||||
func WithService(name string, opts ...func(*dynamic.Service)) func(*dynamic.Service) string {
|
||||
return func(s *dynamic.Service) string {
|
||||
for _, opt := range opts {
|
||||
opt(r)
|
||||
opt(s)
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
func WithServiceServersLoadBalancer(opts ...func(*dynamic.ServersLoadBalancer)) func(*dynamic.Service) {
|
||||
return func(s *dynamic.Service) {
|
||||
b := &dynamic.ServersLoadBalancer{}
|
||||
b.SetDefaults()
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(b)
|
||||
}
|
||||
|
||||
s.LoadBalancer = b
|
||||
}
|
||||
}
|
||||
|
||||
func WithServiceWRR(opts ...func(*dynamic.WeightedRoundRobin)) func(*dynamic.Service) {
|
||||
return func(s *dynamic.Service) {
|
||||
b := &dynamic.WeightedRoundRobin{}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(b)
|
||||
}
|
||||
|
||||
s.Weighted = b
|
||||
}
|
||||
}
|
||||
|
||||
// WithWRRServices is a helper to create a configuration.
|
||||
func WithWRRServices(opts ...func(*dynamic.WRRService)) func(*dynamic.WeightedRoundRobin) {
|
||||
return func(b *dynamic.WeightedRoundRobin) {
|
||||
for _, opt := range opts {
|
||||
service := dynamic.WRRService{}
|
||||
opt(&service)
|
||||
b.Services = append(b.Services, service)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithWRRService is a helper to create a configuration.
|
||||
func WithWRRService(name string, opts ...func(*dynamic.WRRService)) func(*dynamic.WRRService) {
|
||||
return func(s *dynamic.WRRService) {
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
s.Name = name
|
||||
}
|
||||
}
|
||||
|
||||
// WithMiddlewares is a helper to create a configuration.
|
||||
func WithMiddlewares(opts ...func(*dynamic.Middleware) string) func(*dynamic.HTTPConfiguration) {
|
||||
return func(c *dynamic.HTTPConfiguration) {
|
||||
@@ -121,6 +164,13 @@ func WithBasicAuth(auth *dynamic.BasicAuth) func(*dynamic.Middleware) {
|
||||
}
|
||||
}
|
||||
|
||||
// WithErrorPage is a helper to create a configuration.
|
||||
func WithErrorPage(errorPage *dynamic.ErrorPage) func(*dynamic.Middleware) {
|
||||
return func(r *dynamic.Middleware) {
|
||||
r.Errors = errorPage
|
||||
}
|
||||
}
|
||||
|
||||
// WithEntryPoints is a helper to create a configuration.
|
||||
func WithEntryPoints(eps ...string) func(*dynamic.Router) {
|
||||
return func(f *dynamic.Router) {
|
||||
|
||||
Reference in New Issue
Block a user