|
From: David K. <Dav...@Ga...> - 2012-10-24 12:50:52
|
Thanks for the reply Bill.
Our requirement is to accept an arbitrary set of name-value set pairs. My
understanding is that with MatrixParam you actually have to know the name
of the key whereas with PathSegment you don't.
I tried to use PathSegment as shown in the documentation but it didn't
behave as documented which is why am wondering whether the documentation
is incorrect:
@GET
@Path("/book/{id}")
public String getBook(@PathParam("id") PathSegment id) {...}
And the given url is
GET http://host.com/library/book;name=EJB 3.0;author=Bill Burke
Using the above example mentioned in the reasteasy docs I get a 404.
I have to use this url to get an answer:
GET http://host.com/library/book/id;name=EJB 3.0;author=Bill Burke
david
--
David Kaspar
On 23/10/2012 19:27, "Bill Burke" <bb...@re...> wrote:
>
>
>On 10/23/2012 12:01 PM, David Kaspar wrote:
>> I am trying to use PathSegment to receive "?an arbitrary set of
>> name-value pairs embedded in a uri path segment". I am following this
>> documentation:
>>
>>
>>http://docs.jboss.org/resteasy/docs/2.3.5.Final/userguide/html_single/#_P
>>athParam_and_PathSegment
>>
>> The endpoint in the example is defined as
>> @GET
>> @Path("/book/{id}")
>> public String getBook(@PathParam("id") PathSegment id) {...}
>>
>> And the given url is
>> GET http://host.com/library/book;name=EJB 3.0;author=Bill Burke
>>
>> The problem is that this url format doesn't work for us (404, the
>> endpoint is not found). To make it work we had to include the / and a
>> placeholder like so:
>> GET http://host.com/library/book/id;name=EJB 3.0;author=Bill Burke
>>
>> Is the documentation correct and we are misusing PathSegment or is the
>> documentation incorrect?
>>
>
>You are misunderstanding how path expressions work
>
>@Path("/book/{id}") expects a segment after /book.
>
>I'd suggest an additional new method:
>
>@Path("/book")
>public String getBook(@MatixParam("name") String name,
>@MatrixParam("author") String author) {...}
>
>FYI, I don't use matrix parameters anymore. I've found that some
>non-Java URI parsing APIs don't parse them very well (particularly
>Python). I'd suggest using query parameters.
>
>--
>Bill Burke
>JBoss, a division of Red Hat
>http://bill.burkecentral.com
>
>--------------------------------------------------------------------------
>----
>Everyone hates slow websites. So do we.
>Make your web apps faster with AppDynamics
>Download AppDynamics Lite for free today:
>http://p.sf.net/sfu/appdyn_sfd2d_oct
>_______________________________________________
>Resteasy-developers mailing list
>Res...@li...
>https://lists.sourceforge.net/lists/listinfo/resteasy-developers
|