Skip to content

How can I add contextRoot in Helidon SE? #7707

Answered by romain-grecourt
mrguamos asked this question in Q&A
Discussion options

You must be logged in to vote

Use a path when you register handlers and services.

If you have a simple layout with just handlers, simply add a prefix to your paths:

routing.get("/acme/foo", (req, res) -> res.send("Foo"))
        .get("/acme/bar", (req, res) -> res.send("Bar"));

// /acme/foo -> "Foo"
// /acme/bar -> "Bar"

You can use services to group handlers under a common path:

routing.register("/acme", rules ->
        rules.get("/foo", (req, res) -> res.send("Foo"))
                .get("/bar", (req, res) -> res.send("Bar")));

// /acme/foo -> "Foo"
// /acme/bar -> "Bar"

Services can register nested services:

routing.register("/acme", rules1 ->
        rules1.register("/api", rules2 ->
                rules2.get("…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by romain-grecourt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants