views:

56

answers:

2

Hello my fellow stackers

I'm sitting reading on some REST with my fellow teammates, we are writing a RoR application that is going to expose some of its functionality to the rest of the world.

My task on this team is to make a ressource that exposes journal reports. If you call

http://root.com/journalreports

You should get all the journalreports from the service. Thats working like a charm, but I'm confused on how to properly make a ressource that exposes a range of journalreports. Should I make it

http://root.com/journalreports?range=1/2/2010;5/2/2010

Or is this illegal when we talk about REST because of the ?range= interference?

What is the most proper way of giving a REST ressource some parameters?

+2  A: 

REST doesn't make query parameter "illegal" in any way. It's an architectural style, mainly about driving the application by exchanging representations. Considering URIs are meant to be opaque, there's no real difference between http://example.com/page/1 and http://example/?page=1 for example, as far as REST is concerned (it ultimately depends on the representations that are sent, but the choice or URI style tends to be an implementation detail).

What matters is how the client are going to find out about the URIs of your reports. HTML can do this very well with forms and query parameters. Whether your service is for browser consumption or another agent doesn't really matter, you can use the same principles. You could have HTML forms (or equivalent if your client isn't a browser) if you want it to be more flexible or via explicit links on your top page. (You may find it's easier to split the range into two parameters, like "from" and "to", if you want this to be more dynamic.)

Bruno
I actually thought that such "php style" was illegal when doing REST. But maybe I have read something wrong, when I was skimming some articles?
mslot
+2  A: 

Parameters are perfectly OK, especially for search-resources like in your case (querying a set of journals).

I recently answered similar question (path vs. parameter)

manuel aldana
Thanks for the link!! That helped me alot because of the link to the http://labs.apache.org/webarch/uri/rfc/rfc3986.html#query
mslot
I have accepted this because of the link that helped me.
mslot