Path param can NOT be resolved in register method of Service
See original GitHub issueEnvironment Details
- Helidon Version: 0.10.0
- Helidon SE
- JDK version: java version “1.8.0_181”
- OS: Windows 10
- Docker version (if applicable):
Problem Description
Currently the Service
provides a update method to define routine rules, but it can not provides concept like Jaxrs Resource and sub resource, the path params can NOT be resolved in register
method.
Steps to reproduce
Imagine the following case.
I want to build comments api under a certain post, I could design APIs like this.
/posts/post-id/comments
I would like register it in the PostService
like this:
@Override
public void update(Routing.Rules rules) {
rules.get("/", this::getAllPosts)
.post("/", this::savePost)
.get("/{id}", this::getPostById)
.put("/{id}", this::updatePost)
.delete("/{id}", this::deletePostById);
.register("/{id}/comments", new CommentService());
}
And in the CommentService
:
@Override
public void update(Routing.Rules rules) {
rules.get("/", this::getAllComments)
.post("/", Handler.of(JsonObject.class, this::saveComment, this::errorHandler));
}
All uri path in CommentService should be appended /{id}/comments, and all path params should be resolved in CommentService, eg post id in the path.
post id in /{id}/comments is null, check my sample, https://github.com/hantsy/helidon-sample/blob/master/quickstart-se/src/main/java/io/helidon/examples/quickstart/se/CommentService.java#L37.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Path param can NOT be resolved in register method of Service
Currently the Service provides a update method to define routine rules, but it can not provides concept like Jaxrs Resource and sub resource, ......
Read more >Cannot handle request by requestMapping - Stack Overflow
You can handle it using PathVariable and RequestParam annotation. In below code name is thisisname part and city is query param city value....
Read more >Passing Parameters to Resolve — Autofac 6.0.0 documentation
ResolvedParameter can be used as a way to supply values dynamically retrieved from the container, e.g. by resolving a service by name. Parameters...
Read more >PathParam Interface | Microsoft Learn
A parameter that is annotated with PathParam will be ignored if the "uri template" does not contain a path segment variable with name...
Read more >Path (Java Platform SE 7 ) - Oracle Help Center
Registers the file located by this path with a watch service. ... This method does not access the file system; the path or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@romain-grecourt and I dug into this and it looks like a bug. Proposed fix (needs a bit more verification):
@barchetta @romain-grecourt Could we add a test for that as part of the PR?