Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Route SPI not requiring Vert.x HTTP #38143

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import io.quarkus.info.runtime.spi.InfoContributor;
import io.quarkus.maven.dependency.ResolvedDependency;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.deployment.spi.RouteBuildItem;

public class InfoProcessor {

Expand Down Expand Up @@ -283,14 +283,12 @@ RouteBuildItem defineRoute(InfoBuildTimeConfig buildTimeConfig,
List<InfoContributor> infoContributors = contributors.stream()
.map(InfoBuildTimeContributorBuildItem::getInfoContributor)
.collect(Collectors.toList());

unremovableBeanBuildItemBuildProducer.produce(UnremovableBeanBuildItem.beanTypes(InfoContributor.class));
return nonApplicationRootPathBuildItem.routeBuilder()
.management()
.route(buildTimeConfig.path())
.routeConfigKey("quarkus.info.path")
.handler(recorder.handler(buildTimeInfo, infoContributors))
.displayOnNotFoundPage()
.blockingRoute()

return RouteBuildItem.newManagementRoute(buildTimeConfig.path())
.withRoutePathConfigKey("quarkus.info.path")
.withRequestHandler(recorder.handler(buildTimeInfo, infoContributors))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
import io.quarkus.vertx.http.deployment.FilterBuildItem;
import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.deployment.SecurityInformationBuildItem;
import io.quarkus.vertx.http.deployment.devmode.NotFoundPageDisplayableEndpointBuildItem;
import io.quarkus.vertx.http.deployment.spi.RouteBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceConfiguration;
import io.smallrye.openapi.api.OpenApiConfig;
Expand Down Expand Up @@ -305,32 +305,31 @@ void handler(LaunchModeBuildItem launch,
}
}

routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-openapi.management.enabled")
.routeFunction(openApiConfig.path, corsFilter)
.routeConfigKey("quarkus.smallrye-openapi.path")
.handler(handler)
routes.produce(RouteBuildItem.newManagementRoute(openApiConfig.path, "quarkus.smallrye-openapi.management.enabled")
.withRouteCustomizer(corsFilter)
.withRoutePathConfigKey("quarkus.smallrye-openapi.path")
.withRequestHandler(handler)
.displayOnNotFoundPage("Open API Schema document")
.blockingRoute()
.asBlockingRoute()
.build());

routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-openapi.management.enabled")
.routeFunction(openApiConfig.path + ".json", corsFilter)
.handler(handler)
.build());

routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-openapi.management.enabled")
.routeFunction(openApiConfig.path + ".yaml", corsFilter)
.handler(handler)
.build());

routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.management("quarkus.smallrye-openapi.management.enabled")
.routeFunction(openApiConfig.path + ".yml", corsFilter)
.handler(handler)
.build());
routes.produce(
RouteBuildItem.newManagementRoute(openApiConfig.path + ".json", "quarkus.smallrye-openapi.management.enabled")
.withRouteCustomizer(corsFilter)
.withRequestHandler(handler)
.build());

routes.produce(
RouteBuildItem.newManagementRoute(openApiConfig.path + ".yaml", "quarkus.smallrye-openapi.management.enabled")
.withRouteCustomizer(corsFilter)
.withRequestHandler(handler)
.build());

routes.produce(
RouteBuildItem.newManagementRoute(openApiConfig.path + ".yml", "quarkus.smallrye-openapi.management.enabled")
.withRouteCustomizer(corsFilter)
.withRequestHandler(handler)
.build());

// If management is enabled and swagger-ui is part of management, we need to add CORS so that swagger can hit the endpoint
if (isManagement(managementInterfaceBuildTimeConfig, openApiConfig, launch)) {
Expand Down
5 changes: 5 additions & 0 deletions extensions/vertx-http/deployment-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
</dependency>
Comment on lines +21 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to add this dependency? The idea would be to not depend on anything Vert.x right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's necessary, but as far as I'm concerned, it's fine. A mandatory dependency in the deployment artifact is acceptable as long as it can be optional at runtime (and from what I see in Marko 's PR, it can be).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to clarify, the initial goal was to make the dependency optional at runtime, though Clément may have gone a bit further here)

</dependencies>

</project>
Loading
Loading