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

Explain why @PathParam may be optional in this case #31913

Merged
merged 1 commit into from
Mar 17, 2023
Merged
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
4 changes: 3 additions & 1 deletion docs/src/main/asciidoc/qute.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,16 @@ public class ItemResource {
@GET
@Path("{id}")
@Produces(MediaType.TEXT_HTML)
public TemplateInstance get(Integer id) {
public TemplateInstance get(@PathParam("id") Integer id) {
return Templates.item(service.findItem(id)); <2>
}
}
----
<1> Declare a method that gives us a `TemplateInstance` for `templates/ItemResource/item.html` and declare its `Item item` parameter so we can validate the template.
<2> Make the `Item` object accessible in the template.

NOTE: When the `--parameters` compiler argument is enabled, RESTEasy Reactive may infer the parameter names from the method argument names, making the `@PathParam("id")` annotation optional in this case.

=== Template parameter declaration inside the template itself

Alternatively, you can declare your template parameters in the template file itself.
Expand Down