From 5697e1fc3a2f025cde0c04f7bc26941f6df63a83 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 14 Oct 2024 12:00:00 +0200 Subject: [PATCH] Feature flags --- .../numportal/NumPortalApplication.java | 5 ++-- .../properties/FeatureProperties.java | 9 +++++++ .../web/controller/FeatureController.java | 25 +++++++++++++++++++ src/main/resources/application-local.yml | 2 ++ .../numportal/TestNumPortalApplication.java | 5 ++-- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/highmed/numportal/properties/FeatureProperties.java create mode 100644 src/main/java/org/highmed/numportal/web/controller/FeatureController.java diff --git a/src/main/java/org/highmed/numportal/NumPortalApplication.java b/src/main/java/org/highmed/numportal/NumPortalApplication.java index 04be6b67..ba8d655f 100644 --- a/src/main/java/org/highmed/numportal/NumPortalApplication.java +++ b/src/main/java/org/highmed/numportal/NumPortalApplication.java @@ -1,8 +1,7 @@ package org.highmed.numportal; - +import org.highmed.numportal.properties.FeatureProperties; import org.highmed.numportal.service.atna.AtnaProperties; - import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -12,7 +11,7 @@ @EnableScheduling @EnableAsync @SpringBootApplication -@EnableConfigurationProperties({AtnaProperties.class}) +@EnableConfigurationProperties({AtnaProperties.class, FeatureProperties.class}) public class NumPortalApplication { public static void main(String[] args) { diff --git a/src/main/java/org/highmed/numportal/properties/FeatureProperties.java b/src/main/java/org/highmed/numportal/properties/FeatureProperties.java new file mode 100644 index 00000000..1cb9144b --- /dev/null +++ b/src/main/java/org/highmed/numportal/properties/FeatureProperties.java @@ -0,0 +1,9 @@ +package org.highmed.numportal.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@Data +@ConfigurationProperties(prefix = "feature") +public class FeatureProperties { +} diff --git a/src/main/java/org/highmed/numportal/web/controller/FeatureController.java b/src/main/java/org/highmed/numportal/web/controller/FeatureController.java new file mode 100644 index 00000000..2c32c004 --- /dev/null +++ b/src/main/java/org/highmed/numportal/web/controller/FeatureController.java @@ -0,0 +1,25 @@ +package org.highmed.numportal.web.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import lombok.AllArgsConstructor; +import org.highmed.numportal.properties.FeatureProperties; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping(value = "/feature", produces = "application/json") +@SecurityRequirement(name = "security_auth") +public class FeatureController { + + FeatureProperties featureProperties; + + @GetMapping + @Operation(description = "Get feature flags") + public ResponseEntity getFeatureFlags() { + return ResponseEntity.ok(featureProperties); + } +} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index ace7f238..a3075bdf 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -105,3 +105,5 @@ num: user-service: delete-users-cron: 0 0 5 * * * + +feature: diff --git a/src/test/java/org/highmed/numportal/TestNumPortalApplication.java b/src/test/java/org/highmed/numportal/TestNumPortalApplication.java index 7745dea1..457c2e5c 100644 --- a/src/test/java/org/highmed/numportal/TestNumPortalApplication.java +++ b/src/test/java/org/highmed/numportal/TestNumPortalApplication.java @@ -1,6 +1,7 @@ package org.highmed.numportal; import org.highmed.numportal.listeners.UserCacheInit; +import org.highmed.numportal.properties.FeatureProperties; import org.highmed.numportal.service.atna.AtnaProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -8,11 +9,9 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.scheduling.annotation.EnableAsync; -import org.highmed.numportal.listeners.UserCacheInit; -import org.highmed.numportal.service.atna.AtnaProperties; @SpringBootApplication -@EnableConfigurationProperties({AtnaProperties.class}) +@EnableConfigurationProperties({AtnaProperties.class, FeatureProperties.class}) @EnableAsync @ComponentScan(excludeFilters = @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE,