diff --git a/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java b/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java index 6338b7fe2f8e9..906683e4df894 100644 --- a/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java +++ b/extensions/reactive-routes/deployment/src/main/java/io/quarkus/vertx/web/deployment/ReactiveRoutesProcessor.java @@ -369,10 +369,11 @@ public boolean test(String name) { } } else { // Path param set - if (!pathValue.asString().startsWith(SLASH)) { + String pathValueStr = pathValue.asString(); + if (!pathValueStr.isEmpty() && !pathValueStr.startsWith(SLASH)) { prefixed.append(SLASH); } - prefixed.append(pathValue.asString()); + prefixed.append(pathValueStr); } path = prefixed.toString(); } else { diff --git a/extensions/reactive-routes/deployment/src/test/java/io/quarkus/vertx/web/base/RouteBaseTest.java b/extensions/reactive-routes/deployment/src/test/java/io/quarkus/vertx/web/base/RouteBaseTest.java index 9534adfbddbe8..a251da42fe068 100644 --- a/extensions/reactive-routes/deployment/src/test/java/io/quarkus/vertx/web/base/RouteBaseTest.java +++ b/extensions/reactive-routes/deployment/src/test/java/io/quarkus/vertx/web/base/RouteBaseTest.java @@ -22,6 +22,8 @@ public class RouteBaseTest { public void testPath() { when().get("/hello").then().statusCode(200).body(is("Hello world!")); when().get("/simple/hello").then().statusCode(200).body(is("Hello another world!")); + when().get("/simple").then().statusCode(200).body(is("Hello root!")); + when().get("/simple/").then().statusCode(200).body(is("Hello root!")); when().get("/some/foo").then().statusCode(200).body(is("Hello foo!")); } @@ -34,7 +36,7 @@ public void testProduces() { @RouteBase static class SimpleBean { - @Route(path = "hello") // -> "/simple-bean/hello" + @Route(path = "hello") // -> "/hello" void hello(RoutingContext context) { context.response().end("Hello world!"); } @@ -44,6 +46,11 @@ void hello(RoutingContext context) { @RouteBase(path = "simple") static class AnotherBean { + @Route(path = "") // -> "/simple" + void root(RoutingContext context) { + context.response().end("Hello root!"); + } + @Route // path is derived from the method name -> "/simple/hello" void hello(RoutingContext context) { context.response().end("Hello another world!");