Skip to content

Commit

Permalink
Explain why @PathParam may be optional in this case
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Mar 16, 2023
1 parent 012085e commit d4ff711
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit d4ff711

Please sign in to comment.