Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Update context-root config documentation #8427

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[]
}
Loading