Re: Collections and special cases

Jan Algermissen <[email protected]>
Newsgroups gmane.comp.web.services.rest
Message-ID <[email protected]>
On 14.01.2013, at 11:10, "risseraka" <[email protected]> wrote:

> The study case is where you have a collection of programs and you are trying to get the currently running program out of this collection.
> 
> Till now, I have come up with two solutions:
> 
> 1. /programs?current
> 2. /programs/live
> 
> 1. can be understood like applying a sort of filter on the "programs" collection using a "current" query parameter.

Yes. You can think of query parameters to work sort of like the WHERE-condition in an SQL select statement.

> 
> 2. uses the /entities/{id} schema with a non numerical id, "live".

The issue with using a new URL path segment is that the path segment hierarchy in a URL *does* have a meaning - '/' is not just *any* character. So you can think of /{id} in your case to be a sub-'bucket' of your overall 'entities' space.

> 
> Whereas my personal preference goes for the first solution, my guts get a bit fuzzy with trying to get a single item hitting directly on the collection end-point.

Agreed - your scenario is 'indexing' into the collection not a 'sub bucket'. You could, of course, argue about this a lot - here are two things to consider:

- do you maybe have more filters that work in parallel? This makes the first solution obviously better.
- Implementation-wise the first solution is usually cleaner, because {id} will always denote an ID in your code, no special if(id == "live") needed.

> 
> In both cases a 302 Moved Temporarily is performed(?) to redirect to the live program's URI, /programs/1234 with "1234" being the current program's id.

Yes, makes sense.


Jan


> 
> I hope I'm not making a complete fool out of myself and the entire REST community.
> Thanks in advance for your patience!
> 
> Adrien.
> 
> 



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/rest-discuss/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/rest-discuss/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.