2018-11-14 09:18:03 +00:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-07-15 15:04:04 +00:00
|
|
|
"github.com/containous/traefik/pkg/config/runtime"
|
2019-03-15 08:42:03 +00:00
|
|
|
"github.com/containous/traefik/pkg/config/static"
|
|
|
|
"github.com/containous/traefik/pkg/provider/acme"
|
|
|
|
"github.com/containous/traefik/pkg/server/middleware"
|
|
|
|
"github.com/containous/traefik/pkg/types"
|
2018-11-14 09:18:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewRouteAppenderFactory Creates a new RouteAppenderFactory
|
2019-07-19 09:52:04 +00:00
|
|
|
func NewRouteAppenderFactory(staticConfiguration static.Configuration, entryPointName string, acmeProvider []*acme.Provider) *RouteAppenderFactory {
|
2018-11-14 09:18:03 +00:00
|
|
|
return &RouteAppenderFactory{
|
|
|
|
staticConfiguration: staticConfiguration,
|
|
|
|
entryPointName: entryPointName,
|
|
|
|
acmeProvider: acmeProvider,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RouteAppenderFactory A factory of RouteAppender
|
|
|
|
type RouteAppenderFactory struct {
|
|
|
|
staticConfiguration static.Configuration
|
|
|
|
entryPointName string
|
2019-07-19 09:52:04 +00:00
|
|
|
acmeProvider []*acme.Provider
|
2018-11-14 09:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewAppender Creates a new RouteAppender
|
2019-07-15 15:04:04 +00:00
|
|
|
func (r *RouteAppenderFactory) NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *runtime.Configuration) types.RouteAppender {
|
2019-05-16 08:58:06 +00:00
|
|
|
aggregator := NewRouteAppenderAggregator(ctx, middlewaresBuilder, r.staticConfiguration, r.entryPointName, runtimeConfiguration)
|
2018-11-14 09:18:03 +00:00
|
|
|
|
2019-07-19 09:52:04 +00:00
|
|
|
for _, p := range r.acmeProvider {
|
|
|
|
if p != nil && p.HTTPChallenge != nil && p.HTTPChallenge.EntryPoint == r.entryPointName {
|
|
|
|
aggregator.AddAppender(p)
|
|
|
|
break
|
|
|
|
}
|
2018-11-14 09:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return aggregator
|
|
|
|
}
|