Skip to content

Commit

Permalink
Merge pull request #247 from SpeedsterF2/management-interface
Browse files Browse the repository at this point in the history
Honor management interface if enabled
  • Loading branch information
phillip-kruger authored Nov 15, 2023
2 parents ad6de9e + ac4d44c commit fc37d8f
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.quarkus.vertx.http.deployment.BodyHandlerBuildItem;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

Expand Down Expand Up @@ -44,7 +45,8 @@ void includeRestEndpoints(BuildProducer<RouteBuildItem> routeProducer,
BodyHandlerBuildItem bodyHandlerBuildItem,
LoggerManagerRecorder recorder,
LaunchModeBuildItem launchMode,
LoggingManagerRuntimeConfig runtimeConfig) {
LoggingManagerRuntimeConfig runtimeConfig,
ManagementInterfaceBuildTimeConfig managementConfig) {

if ("/".equals(loggingManagerConfig.basePath)) {
throw new ConfigurationException(
Expand All @@ -56,13 +58,15 @@ void includeRestEndpoints(BuildProducer<RouteBuildItem> routeProducer,
Handler<RoutingContext> levelHandler = recorder.levelHandler();

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management()
.routeFunction(loggingManagerConfig.basePath,
recorder.routeConsumer(bodyHandlerBuildItem.getHandler(), runtimeConfig))
.displayOnNotFoundPage("All available loggers")
.handler(loggerHandler)
.build());

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management()
.nestedRoute(loggingManagerConfig.basePath, "levels")
.displayOnNotFoundPage("All available log levels")
.handler(levelHandler)
Expand All @@ -75,10 +79,11 @@ public void includeInOpenAPIEndpoint(BuildProducer<AddToOpenAPIDefinitionBuildIt
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
Capabilities capabilities,
LaunchModeBuildItem launchMode,
LoggingManagerConfig loggingManagerConfig) {
LoggingManagerConfig loggingManagerConfig,
ManagementInterfaceBuildTimeConfig managementConfig) {

// Add to OpenAPI if OpenAPI is available
if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI) && shouldInclude(launchMode, loggingManagerConfig)) {
if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI) && shouldIncludeInOpenAPI(launchMode, loggingManagerConfig, managementConfig)) {
LoggingManagerOpenAPIFilter filter = new LoggingManagerOpenAPIFilter(
nonApplicationRootPathBuildItem.resolvePath(loggingManagerConfig.basePath),
loggingManagerConfig.openapiTag);
Expand All @@ -90,4 +95,8 @@ private static boolean shouldInclude(LaunchModeBuildItem launchMode, LoggingMana
return launchMode.getLaunchMode().isDevOrTest() || loggingManagerConfig.alwaysInclude;
}

private static boolean shouldIncludeInOpenAPI(LaunchModeBuildItem launchMode, LoggingManagerConfig loggingManagerConfig, ManagementInterfaceBuildTimeConfig managementConfig) {
return !managementConfig.enabled && shouldInclude(launchMode, loggingManagerConfig);
}

}

0 comments on commit fc37d8f

Please sign in to comment.