I am trying to design an application using a REST style, however, I am unsure of the correct way to handle a page which has multiple resources being displayed, such as hotel rooms and advertisements; or a page that displays the most recent items from a collection and also the least recent. Does anyone have any idea how I would go about doing this, or any suggestions of where I can go to find more information on this particular issue? Thanks.
on 2007-05-28 21:56
on 2007-05-28 23:28
There are many opinions I am sure. I would say that REST is more about information than presentation. More about services to be put together than monolithic web pages. Using that perspective a web page that wants to present several resources should access the resources individually as separate components. Rails has not gotten to the point where this is well supported however. There is some support in edge for nested resources, but the last I heard it was not yet stable. Using that model you would have resources for the composite view and for each component resources. But, basically unless you are presenting very simple information presentations REST is less about the browser and more about information access by other programs. So while your web page may be at /summary/something you may make each piece available separately as well. /rooms /advertisements /items/recent and /items/old or whatever. What REST does advocate is that there are a limited number of operations GET, PUT, POST, DELETE and a URI used to obtain a resource should be used in a PUT to update the resources, and in DELETE to delete the resource. So if you have a web page that shows rooms and advertisements, and a teaser of recent news items, you should be able to delete all of them with a DELETE request to the same URI (right? :-)) Obviously this is not true. Web pages are presentation, and need to be treated a bit different than services. Michael
on 2007-05-29 00:21
Thank you for your response. Just a few comments. So am I correct in saying that this situation suggests that I should develop the web application in a more RPC style way, being that REST will not support returning multiple resources? Therefore I should save any REST style interactions for when there is a single resource I am returning that I want to expose as a service? Nested resources seem as if they would only allow me to nest one child element, any idea what would happen when I have multiple children on a resource. Are there any other opinions out there on this?