diff --git a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc index 91037e38ff3..c4d3d9fae2d 100644 --- a/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc +++ b/docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc @@ -64,7 +64,46 @@ in each subclass using the collections in steps (2) and (3) only as defaults, i. both return empty sets. NOTE: Helidon treats `@Path` and `@Provided` as bean-defining annotations but, as stated above, -`Application` subclasses may require additional annotations depending on the discovery mode. +`Application` subclasses may require additional annotations depending on the discovery mode + +== Setting Application Path + +The application path, also known as context root, is the base URI used to serve all resource URIs provided +by `@Path` annotation. This section describes how to set it with an annotation or configuration file. + +When an `Application` subclass is provided, use the `@ApplicationPath`: + +[source,java] +---- +include::{sourcedir}/mp/jaxrs/JaxrsApplicationsSnippets.java[tag=snippet_2, indent=0] +---- + +The served resources can be reached through `/my-application/{myResources}` endpoint. It can be overridden +by configuration file. + +Example of custom application path using `.yaml` file: + +[source,yaml] +---- +io.helidon.examples.MyApplication: + routing-path: + path: "/my-application" +---- + +The same configuration works for `.properties` file: + +[source,properties] +---- +io.helidon.examples.MyApplication.routing-path.path=/my-application +---- + +If an `Application` is not provided, a _synthetic_ subclass is created and can be configured using +this property: + +[source,properties] +---- +jakarta.ws.rs.core.Application.routing-path.path=/my-application +---- == Access to Application Instances diff --git a/docs/src/main/asciidoc/mp/server.adoc b/docs/src/main/asciidoc/mp/server.adoc index dfe5087ad86..4951dbc3513 100644 --- a/docs/src/main/asciidoc/mp/server.adoc +++ b/docs/src/main/asciidoc/mp/server.adoc @@ -300,7 +300,8 @@ You can configure `@RoutingPath` to define the path a service is registered on. ===== Configuration override of routing path For each HTTP service class you can define the routing path by specifying a configuration -option `class-name.routing-path.path`. +option `class-name.routing-path.path`. The `routing-path` configuration can be applied to Jax-RS application. +See xref:jaxrs/jaxrs-applications.adoc[Jakarta REST Application] for more information. Example (YAML) configuration for a class `io.helidon.example.AdminService` that changes the routing path to `/management`: diff --git a/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java b/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java index e60c4a7391a..0f16275afee 100644 --- a/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java +++ b/docs/src/main/java/io/helidon/docs/mp/jaxrs/JaxrsApplicationsSnippets.java @@ -17,6 +17,7 @@ import io.helidon.webserver.http.ServerRequest; +import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.core.Application; @@ -36,4 +37,10 @@ public void get(@Context ServerRequest serverRequest) { } // end::snippet_1[] + // tag::snippet_2[] + @ApplicationPath("/my-application") + public class MyApplication extends Application { + + } + // end::snippet_2[] }