users@jersey.java.net

[Jersey] Re: Specifying different sub-resources depending on the Content-Type?

From: Cameron Heavon-Jones <cmhjones_at_gmail.com>
Date: Tue, 21 Jun 2011 11:41:37 +0100

On 21/06/2011, at 8:02 AM, John Lister wrote:

> I'm a bit late to this thread, if you really want to return different types based on the mime type, would you not use "application/json+iphone", etc and maintain the json link.

Yes, this would seem the most prudent so that maybe other json tools can also use the data?

>
> Secondly in these situations, I prefer to leave the annotations to a minimum and handle the logic in the code, I find it makes the things cleaner without having multiple duplicated functions, for example:
>
> @GET
> @PATH("/device/{id}")
> public Object getDevice(@PathParam("id") Integer id){
> // lookup device based on headers and query params, throwing a custom exception if not valid
> return deviceLookup(id);
> }
>
> But I imagine that is a whole separate thread topic :)
>
> John

I agree, as soon as there are multiple different-but-slightly-similar dispatch methods, it's way easier to just get the query and headers from a map when and where they're needed.

cam