Integration of routes that are not resources in an MVC REST style application

Posted by Emil Lerch on Programmers See other posts from Programmers or by Emil Lerch
Published on 2011-10-20T15:07:18Z Indexed on 2012/03/20 23:39 UTC
Read the original article Hit count: 363

Filed under:
|
|

I would like to keep my application relatively REST-pure for the sake of consistency, but I'm struggling philosophically with the relatively few views (maybe just one) that I'll need to build that don't relate to resources directly, and therefore do not fit into a REST style.

As an example, take the home page. Ruby on rails seems to bail on their otherwise RESTful approach for this very basic need of all web sites. The home page appears special:

  • You can get it, but a get at the resource level is supposed to give you a collection of elements. I can imagine this being the list of routes maybe, but that seems a stretch, and doesn't address anything else.
  • Getting the home page by id doesn't seem to make a whole lot of sense - what's the element of a home collection? Again, maybe routes, but a get on a route would do what? Redirect? This feels odd.
  • You can't delete it (arguably you could allow this for administrators)
  • Adding a second one doesn't make sense except possibly if the elements were routes
  • Updating it might make sense for administrators, but AFAIK REST doesn't describe updates on the resource directly, only elements of the resource (this article explicitly says "UNUSED" for PUTS on the resource)

Is the "right" thing to do just to special case these types of things? At the end of the day, I can wrap my head around most of applications being gathered around resources...I can't think of another good example other than a home page, but since that's the start of an application, I think it warrants some thought.

© Programmers or respective owner

Related posts about web-development

Related posts about design