jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] _at_Default and _at_PathParam?

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 16 May 2013 21:02:46 +0100

On 16/05/13 17:51, Santiago Pericas-Geertsen wrote:
>
> On May 16, 2013, at 10:00 AM, Bill Burke <bburke_at_redhat.com> wrote:
>
>> Does @Default on a @PathParam even make sense?
>
> It's a good question. I suppose a method can be matched in different ways as follows:
>
> @Path("widgets")
> public class WidgetsResource {
>
> @Path("{id}")
> public WidgetResource findWidget(@PathParam("id") String id) {
> return new WidgetResource(id);
> }
> }
>
> @Path("boxed-widgets/{box}")
> public class WidgetsBoxResource {
>
> @Path("{id}")
> public WidgetResource findWidget(@PathParam("id") String id) {
> return new WidgetResource(id);
> }
> }
>
> public class WidgetResource {
> public WidgetResource(String id) {...}
>
> @GET
> public Widget getDetails(@Default("no-box") @PathParam("box") String box) {...}
> }
>
> and the URLs,
>
> /widgets/25
> /boxed-widgets/box1/25
>
> Does that make sense?
Nice example.

The other option is when we have a custom regular expression ? The
resource method would accept both /widgets/25 & /widgets and in the
latter case the id can be defaulted too

Cheers, Sergey

>
> -- Santiago
>