add static redirect

This commit is contained in:
Manuel Zapf 2018-10-29 16:48:06 +01:00 committed by Traefiker Bot
parent 993caf5058
commit c6dd1dccc3
5 changed files with 21 additions and 36 deletions

View file

@ -42,13 +42,7 @@ func (s *Server) loadConfiguration(configMsg types.ConfigMessage) {
s.metricsRegistry.ConfigReloadsCounter().Add(1)
newServerEntryPoints, err := s.loadConfig(newConfigurations, s.globalConfiguration)
if err != nil {
s.metricsRegistry.ConfigReloadsFailureCounter().Add(1)
s.metricsRegistry.LastConfigReloadFailureGauge().Set(float64(time.Now().Unix()))
log.Error("Error loading new configuration, aborted ", err)
return
}
newServerEntryPoints := s.loadConfig(newConfigurations, s.globalConfiguration)
s.metricsRegistry.LastConfigReloadSuccessGauge().Set(float64(time.Now().Unix()))
@ -77,11 +71,7 @@ func (s *Server) loadConfiguration(configMsg types.ConfigMessage) {
// loadConfig returns a new gorilla.mux Route from the specified global configuration and the dynamic
// provider configurations.
func (s *Server) loadConfig(configurations types.Configurations, globalConfiguration configuration.GlobalConfiguration) (map[string]*serverEntryPoint, error) {
redirectHandlers, err := s.buildEntryPointRedirect()
if err != nil {
return nil, err
}
func (s *Server) loadConfig(configurations types.Configurations, globalConfiguration configuration.GlobalConfiguration) map[string]*serverEntryPoint {
serverEntryPoints := s.buildServerEntryPoints()
@ -95,7 +85,7 @@ func (s *Server) loadConfig(configurations types.Configurations, globalConfigura
for _, frontendName := range frontendNames {
frontendPostConfigs, err := s.loadFrontendConfig(providerName, frontendName, config,
redirectHandlers, serverEntryPoints,
serverEntryPoints,
backendsHandlers, backendsHealthCheck)
if err != nil {
log.Errorf("%v. Skipping frontend %s...", err, frontendName)
@ -128,12 +118,12 @@ func (s *Server) loadConfig(configurations types.Configurations, globalConfigura
}
}
return serverEntryPoints, err
return serverEntryPoints
}
func (s *Server) loadFrontendConfig(
providerName string, frontendName string, config *types.Configuration,
redirectHandlers map[string]negroni.Handler, serverEntryPoints map[string]*serverEntryPoint,
serverEntryPoints map[string]*serverEntryPoint,
backendsHandlers map[string]http.Handler, backendsHealthCheck map[string]*healthcheck.BackendConfig,
) ([]handlerPostConfig, error) {
@ -194,10 +184,6 @@ func (s *Server) loadFrontendConfig(
n := negroni.New()
if _, exist := redirectHandlers[entryPointName]; exist {
n.Use(redirectHandlers[entryPointName])
}
for _, handler := range handlers {
n.Use(handler)
}