diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/ResourceLocatorTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/ResourceLocatorTest.java index 0ea317fca1a22..2f610a82cce42 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/ResourceLocatorTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/ResourceLocatorTest.java @@ -61,6 +61,7 @@ public static void close() { @RegisterExtension static QuarkusUnitTest testExtension = new QuarkusUnitTest() + .overrideConfigKey("quarkus.http.root-path", "/app") .setArchiveProducer(new Supplier<>() { @Override public JavaArchive get() { @@ -155,4 +156,9 @@ public void testBeanParamsInSubresource() { .then() .body(is("first and second")); } + + @Test + public void testRoot() throws Exception { + given().get().then().body(is("[app, ]")); + } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorBaseResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorBaseResource.java index 319833214901b..308a4a738be87 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorBaseResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorBaseResource.java @@ -5,8 +5,10 @@ import java.lang.reflect.Proxy; import java.util.List; +import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.UriInfo; @@ -18,13 +20,21 @@ public class ResourceLocatorBaseResource { private static final Logger LOG = Logger.getLogger(ResourceLocatorBaseResource.class); + @GET + @Produces("*/*") + public String getDefault(@Context UriInfo uri) { + LOG.debug("Here in BaseResource"); + List matchedURIs = uri.getMatchedURIs(); + return matchedURIs.toString(); + } + @Path("base/{param}/resources") public Object getSubresource(@PathParam("param") String param, @Context UriInfo uri) { LOG.debug("Here in BaseResource"); Assertions.assertEquals("1", param); List matchedURIs = uri.getMatchedURIs(); Assertions.assertEquals(2, matchedURIs.size()); - Assertions.assertEquals("base/1/resources", matchedURIs.get(0)); + Assertions.assertEquals("app/base/1/resources", matchedURIs.get(0)); Assertions.assertEquals("", matchedURIs.get(1)); for (String ancestor : matchedURIs) LOG.debug(" " + ancestor); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource.java index febacd2ff7ef2..dfb0d717642ef 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource.java @@ -22,7 +22,7 @@ public String doGet(@Context UriInfo uri) { LOG.info("Uri Ancestors for Subresource.doGet():"); List matchedURIs = uri.getMatchedURIs(); Assertions.assertEquals(2, matchedURIs.size()); - Assertions.assertEquals("base/1/resources", matchedURIs.get(0)); + Assertions.assertEquals("app/base/1/resources", matchedURIs.get(0)); Assertions.assertEquals("", matchedURIs.get(1)); for (String ancestor : matchedURIs) LOG.debug(" " + ancestor); @@ -41,8 +41,8 @@ public Object getSubresource2(@Context UriInfo uri) { LOG.info("Uri Ancestors for Subresource.getSubresource2():"); List matchedURIs = uri.getMatchedURIs(); Assertions.assertEquals(3, matchedURIs.size()); - Assertions.assertEquals("base/1/resources/subresource2", matchedURIs.get(0)); - Assertions.assertEquals("base/1/resources", matchedURIs.get(1)); + Assertions.assertEquals("app/base/1/resources/subresource2", matchedURIs.get(0)); + Assertions.assertEquals("app/base/1/resources", matchedURIs.get(1)); Assertions.assertEquals("", matchedURIs.get(2)); for (String ancestor : matchedURIs) LOG.debug(" " + ancestor); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource2.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource2.java index 637ca33eb0afc..da745c63579ec 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource2.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/resource/basic/resource/ResourceLocatorSubresource2.java @@ -18,9 +18,9 @@ public class ResourceLocatorSubresource2 { public String doGet(@PathParam("param") String param, @Context UriInfo uri) { LOG.debug("Uri Ancestors for Subresource2.doGet():"); Assertions.assertEquals(4, uri.getMatchedURIs().size()); - Assertions.assertEquals("base/1/resources/subresource2/stuff/2/bar", uri.getMatchedURIs().get(0)); - Assertions.assertEquals("base/1/resources/subresource2", uri.getMatchedURIs().get(1)); - Assertions.assertEquals("base/1/resources", uri.getMatchedURIs().get(2)); + Assertions.assertEquals("app/base/1/resources/subresource2/stuff/2/bar", uri.getMatchedURIs().get(0)); + Assertions.assertEquals("app/base/1/resources/subresource2", uri.getMatchedURIs().get(1)); + Assertions.assertEquals("app/base/1/resources", uri.getMatchedURIs().get(2)); Assertions.assertEquals("", uri.getMatchedURIs().get(3)); for (String ancestor : uri.getMatchedURIs()) LOG.debugv(" {0}", ancestor); diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java index 2248a8f7763ac..7e6d9ae949922 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java @@ -428,6 +428,9 @@ public String getPathWithoutPrefix() { if (!prefix.isEmpty()) { // FIXME: can we really have paths that don't start with the prefix if there's a prefix? if (path.startsWith(prefix)) { + if (path.length() == prefix.length()) { + return "/"; + } return path.substring(prefix.length()); } } diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java index 987bbf2838113..7dd314457a2dc 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/UriInfoImpl.java @@ -55,6 +55,9 @@ public String getPath(boolean decode) { if (prefix.isEmpty()) return path; // else skip the prefix + if (path.length() == prefix.length()) { + return "/"; + } return path.substring(prefix.length()); }