Skip to content

Commit

Permalink
Refactoring: extract constant for config key
Browse files Browse the repository at this point in the history
  • Loading branch information
turing85 committed Mar 6, 2024
1 parent 2982ae7 commit 86e15fb
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
class SmallRyeHealthProcessor {
private static final Logger LOG = Logger.getLogger(SmallRyeHealthProcessor.class);

private static final String CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED = "quarkus.smallrye-health.management.enabled";

private static final DotName LIVENESS = DotName.createSimple(Liveness.class.getName());
private static final DotName READINESS = DotName.createSimple(Readiness.class.getName());
private static final DotName STARTUP = DotName.createSimple(Startup.class.getName());
Expand Down Expand Up @@ -211,7 +213,7 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes,

// Register the health handler
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.route(healthConfig.rootPath)
.routeConfigKey("quarkus.smallrye-health.root-path")
.handler(new SmallRyeHealthHandler())
Expand All @@ -220,47 +222,47 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes,

// Register the liveness handler
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.nestedRoute(healthConfig.rootPath, healthConfig.livenessPath)
.handler(new SmallRyeLivenessHandler())
.displayOnNotFoundPage()
.build());

// Register the readiness handler
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.nestedRoute(healthConfig.rootPath, healthConfig.readinessPath)
.handler(new SmallRyeReadinessHandler())
.displayOnNotFoundPage()
.build());

// Register the health group handlers
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.nestedRoute(healthConfig.rootPath, healthConfig.groupPath)
.handler(new SmallRyeHealthGroupHandler())
.displayOnNotFoundPage()
.build());

SmallRyeIndividualHealthGroupHandler handler = new SmallRyeIndividualHealthGroupHandler();
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.nestedRoute(healthConfig.rootPath, healthConfig.groupPath + "/*")
.handler(handler)
.displayOnNotFoundPage()
.build());

// Register the wellness handler
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.nestedRoute(healthConfig.rootPath, healthConfig.wellnessPath)
.handler(new SmallRyeWellnessHandler())
.displayOnNotFoundPage()
.build());

// Register the startup handler
routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.nestedRoute(healthConfig.rootPath, healthConfig.startupPath)
.handler(new SmallRyeStartupHandler())
.displayOnNotFoundPage()
Expand Down Expand Up @@ -420,7 +422,6 @@ void registerHealthUiHandler(
LaunchModeBuildItem launchMode,
SmallRyeHealthConfig healthConfig,
BuildProducer<SmallRyeHealthBuildItem> smallryeHealthBuildProducer, ShutdownContextBuildItem shutdownContext) {

WebJarResultsBuildItem.WebJarResult result = webJarResultsBuildItem.byArtifactKey(HEALTH_UI_WEBJAR_ARTIFACT_KEY);
if (result == null) {
return;
Expand All @@ -435,15 +436,15 @@ void registerHealthUiHandler(
healthUiPath, result.getWebRootConfigurations(), runtimeConfig, shutdownContext);

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.route(healthConfig.ui.rootPath)
.displayOnNotFoundPage("Health UI")
.routeConfigKey("quarkus.smallrye-health.ui.root-path")
.handler(handler)
.build());

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-health.management.enabled")
.management(CONFIG_KEY_HEALTH_MANAGEMENT_ENABLED)
.route(healthConfig.ui.rootPath + "*")
.handler(handler)
.build());
Expand Down

0 comments on commit 86e15fb

Please sign in to comment.