Skip to content

Commit

Permalink
4.x: Update context-root config documentation (#8427)
Browse files Browse the repository at this point in the history
* update documentation

Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin authored Feb 29, 2024
1 parent 61adad5 commit ca2bc73
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
41 changes: 40 additions & 1 deletion docs/src/main/asciidoc/mp/jaxrs/jaxrs-applications.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/src/main/asciidoc/mp/server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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[]
}

0 comments on commit ca2bc73

Please sign in to comment.