users@jersey.java.net

Re: [Jersey] Root resource class question

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 23 Feb 2010 11:52:42 -0500

On Feb 23, 2010, at 11:37 AM, Dário Abdulrehman wrote:

> I thought it would be best to provide two distinct URLs for single and multiple proteins .
> http://blog.roberthahn.ca/articles/2007/04/06/url-design/ (though this is no authoritative source)
>
I think its just a matter of taste. The URIs are distinct regardless of whether the first path segment is plural or singular.

> Are there any style guidelines for URL design?
>
I thought the coverage in the "RESTful Web Services" book by Richardson and Ruby was good.

Marc.

>
> On Tue, Feb 23, 2010 at 3:31 PM, Marc Hadley <Marc.Hadley_at_sun.com> wrote:
> On Feb 23, 2010, at 9:35 AM, Dário Abdulrehman wrote:
>
> > Is it possible to define a single root resource class that matches both:
> >
> > GET /proteins?protein=proteinid1&protein=proteinid2&...
> > GET/protein/proteinid
> >
> > @Path(?)
> > public Class ...
> >
> > and define two @GET methods for each case?
> >
> > Conceptually they are the same resource but one works with lists and the other with single objects.
> >
> Its possible like this:
>
> @Path("/")
> pubic class ProteinResource {
>
> @GET @Path("proteins")
> public getList(...) {...}
>
> @GET @Path("protein")
> public getSingle(...) {...}
> }
>
> But I think Jan's suggestion is much better.
>
> Marc.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>