This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun FF4j.isEnabled(featureName: String): Boolean = this.check(featureName) | |
fun FF4j.isDisabled(featureName: String): Boolean = !this.check(featureName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
class SampleService(private val ff4j: FF4j) { | |
fun callSampleService() { | |
if (ff4j.isEnabled("some-feature")) { | |
print("some-feature is enabled") | |
} | |
if (ff4j.isDisabled("other-feature")) { | |
print("other-feature is disabled") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@ConfigurationProperties("toggles.ff4j") | |
class FF4JProperties { | |
final lateinit var user: String | |
final lateinit var password: String | |
final lateinit var role: String | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toggles: | |
ff4j: | |
user: ff4j | |
password: ff23local | |
role: ADMIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableWebSecurity | |
@Order(1) | |
class FF4jSecurityConfig(private val properties: FF4JProperties): WebSecurityConfigurerAdapter() { | |
override fun configure(auth: AuthenticationManagerBuilder) { | |
auth.inMemoryAuthentication() | |
.withUser(properties.user) | |
.password("{noop}${properties.password}") | |
.roles(properties.role) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@AutoConfigureAfter(FF4jConfiguration::class) | |
@ConditionalOnClass(ConsoleServlet::class, FF4jDispatcherServlet::class) | |
class FF4jServletConfig : SpringBootServletInitializer() { | |
@Bean | |
fun ff4jDispatcherServletRegistrationBean(ff4jDispatcherServlet: FF4jDispatcherServlet?): ServletRegistrationBean<*> { | |
return ServletRegistrationBean(ff4jDispatcherServlet, "/ff4j-web-console/*") | |
} | |
@Bean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
datasource: | |
driver-class-name: org.postgresql.Driver | |
url: jdbc:postgresql://localhost:5432/autofin_api | |
username: postgres | |
password: root | |
# outras configurações.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@ConditionalOnClass(FF4j::class) | |
class FF4jConfiguration(private val dataSource: DataSource) { | |
@Bean | |
fun getFF4j(): FF4j { | |
val ff4j = FF4j() | |
// Conexão com o DB | |
ff4j.featureStore = FeatureStoreSpringJdbc(dataSource) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ff4jVersion = "1.8.2" | |
dependencies { | |
// Other dependencies | |
// Feature Toggles | |
compile("org.ff4j:ff4j-core:${ff4jVersion}") | |
compile("org.ff4j:ff4j-web:${ff4jVersion}") | |
compile("org.ff4j:ff4j-store-springjdbc:$ff4jVersion") | |
compile("org.thymeleaf:thymeleaf:3.0.3.RELEASE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
require 'webmock/rspec' | |
describe ::Toggle::TestToggle do | |
context 'When test_toggle feature toggle is active' do | |
it 'returns enabled' do | |
enable_toggle(:test_feature) | |
expect(described_class.new.show).to eql('Enabled!') | |
end |