
de.otto.edison.togglz.configuration.TogglzConsoleConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edison-togglz Show documentation
Show all versions of edison-togglz Show documentation
Status library of the edison-microservice project.
package de.otto.edison.togglz.configuration;
import de.otto.edison.navigation.NavBar;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.togglz.console.TogglzConsoleServlet;
import static de.otto.edison.navigation.NavBarItem.bottom;
import static de.otto.edison.navigation.NavBarItem.navBarItem;
@Configuration
@EnableConfigurationProperties(value = {TogglzProperties.class})
@ConditionalOnProperty(prefix = "edison.togglz.console", name = "enabled", havingValue = "true", matchIfMissing = true)
public class TogglzConsoleConfiguration {
public static final String TOGGLES_URL_PATTERN = "/toggles/console/*";
@Bean
public ServletRegistrationBean> togglzServlet(final @Value("${edison.application.management.base-path:/internal}") String prefix,
final NavBar rightNavBar, final TogglzProperties properties) {
// Register Togglz Console in the right "Admin" navigation bar:
rightNavBar.register(navBarItem(bottom(), "Feature Toggles", prefix + "/toggles/console"));
// Register TogglzConsoleServlet:
TogglzConsoleServlet togglzConsoleServlet = new TogglzConsoleServlet();
togglzConsoleServlet.setValidateCSRFToken(properties.getConsole().isValidateCSRFToken());
return new ServletRegistrationBean<>(togglzConsoleServlet, prefix + TOGGLES_URL_PATTERN);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy