BAD_SEED
BAD_SEED

Reputation: 5056

How to mantain the RESTful design of my own applications

As far as I know, the peculiarity of a REST web service is the resource concept. Everything should rotate around the resource and its CRUD operations. Suppose that one resource is the player resource, I can retrive player's list at the link http://mydomain.com/players.xml, the 5th player is reachable at http://mydomain.com/players/5.xml, and so on, using proper HTTP method, I can perform different CRUD actions.

Now on the client side the issue is: What if I need to show a table with player's score (you can assume that this table is build on the fly, querying the player's DB table). In my hopinion, this table isn't a real resource (I can't delete table, neither I can't edit or add new table).

Then the real question is (considering I'm using CakePHP framework): What can I do to have my player's table without broke the RESTish style of player's controller?

My first idea is: add method getTable() to prexistent four CRUD methods (index(), view(), edit() and delete()) of players controller, modify the routes.php configuration file in a way that all the REST API will reachable under rest path (i.e. http://mydomain.com/rest/players/5.xml) while all other service, non RESTFUL, will be reachable under nonrest path (i.e. http://mydomain.com/nonrest/players/getTable or http://mydomain.com/nonrest/players/getTable.xml). In this way the API's client will surely know that under the rest path the REST paradigm is respected. Is a good solution? Have you any other idea?

Upvotes: 0

Views: 49

Answers (1)

fumanchu
fumanchu

Reputation: 14559

You don't need a separate nonrest hierarchy; there's absolutely nothing wrong with http://mydomain.com/players/5/score.xml. Just because a resource is read-only does not thereby make it something other than a resource.

Upvotes: 2

Related Questions