diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java index 0dc4b5e1f280c..8f0b9f91369a4 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java @@ -270,6 +270,7 @@ public static class Builder extends RouteBuildItem.Builder { private final NonApplicationRootPathBuildItem buildItem; private RouteBuildItem.RouteType routeType = RouteBuildItem.RouteType.FRAMEWORK_ROUTE; private RouteBuildItem.RouteType routerType = RouteBuildItem.RouteType.FRAMEWORK_ROUTE; + private String name; private String path; Builder(NonApplicationRootPathBuildItem buildItem) { @@ -330,7 +331,13 @@ public Builder orderedRoute(String route, Integer order, Consumer routeFu this.path = route; this.routerType = RouteBuildItem.RouteType.ABSOLUTE_ROUTE; } - super.orderedRoute(this.path, order, routeFunction); + + // we normalize the route name to remove trailing *, this is to be consistent with the path + // see RouteImpl#setPath() + String routeName = route.charAt(route.length() - 1) == '*' ? route.substring(0, route.length() - 1) : route; + + // we pass a route name for proper identification in the metrics + super.orderedRoute(routeName, this.path, order, routeFunction); return this; } diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/RouteBuildItem.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/RouteBuildItem.java index 7156e0db32b43..c4cf342638e4a 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/RouteBuildItem.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/RouteBuildItem.java @@ -176,6 +176,20 @@ public Builder orderedRoute(String route, Integer order, Consumer routeCu return this; } + /** + * @param name The name of the route. It is used to identify the route in the metrics. + * @param route A normalized path used to define a basic route + * (e.g. use HttpRootPathBuildItem to construct/resolve the path value). This path this is also + * used on the "Not Found" page in dev mode. + * @param order Priority ordering of the route + * @param routeCustomizer Route customizer. + */ + public Builder orderedRoute(String name, String route, Integer order, Consumer routeCustomizer) { + this.routeFunction = new BasicRoute(name, route, order, routeCustomizer); + this.notFoundPagePath = this.routePath = route; + return this; + } + public Builder handler(Handler handler) { this.handler = handler; return this; diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BasicRoute.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BasicRoute.java index 064145e894d45..bd5ec80d091a8 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BasicRoute.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/BasicRoute.java @@ -8,6 +8,8 @@ public class BasicRoute implements Function { + private String name; + private String path; private Integer order; @@ -15,15 +17,29 @@ public class BasicRoute implements Function { private Consumer customizer; public BasicRoute(String path) { - this(path, null); + this(null, path); } public BasicRoute(String path, Integer order) { + this(null, path, order); + } + + public BasicRoute(String path, Integer order, Consumer customizer) { + this(null, path, order, customizer); + } + + public BasicRoute(String name, String path) { + this(name, path, null); + } + + public BasicRoute(String name, String path, Integer order) { + this.name = name; this.path = path; this.order = order; } - public BasicRoute(String path, Integer order, Consumer customizer) { + public BasicRoute(String name, String path, Integer order, Consumer customizer) { + this.name = name; this.path = path; this.order = order; this.customizer = customizer; @@ -32,6 +48,14 @@ public BasicRoute(String path, Integer order, Consumer customizer) { public BasicRoute() { } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getPath() { return path; } @@ -60,6 +84,9 @@ public BasicRoute setCustomizer(Consumer customizer) { @Override public Route apply(Router router) { Route route = router.route(path); + if (name != null) { + route.setName(name); + } if (order != null) { route.order(order); }