Issue with routes #255

Closed
javiern opened this Issue Jun 27, 2012 · 5 comments

Comments

Projects
None yet
3 participants

javiern commented Jun 27, 2012

hello, i was reading the documentation of the bundle and find this

public function lockUserAction($slug)
{} // "lock_user" [PATCH] /users/{slug}/lock

public function banUserAction($slug, $id)
{} // "ban_user"     [PATCH] /users/{slug}/ban

public function removeUserAction($slug)
{} // "remove_user"  [GET] /users/{slug}/remove

This kind of routing is NOT RESTful, its just RPC. in rest, u dont use the verb in the URI.
in the example above, the correct routing could be

public function updateUserAction($slug)
{} // "update_user lock, ban, or whatever"    [PATCH] /users/{slug} or [POST] /users/{slug} or  [PUT] /users/{slug} (if idempotent action)

public function removeUserAction($slug)
{} // "remove_user"  [DELETE] /users/{slug}

REST is about transfering representions of resources, not about excution actions on resources.

In a rest architecture, you dont ask the server to BAN a user, You transfer to the server a REPRESENTATION OF THE BANNED user, and the server decides if he stores your representation of the resource...

Owner

stof commented Jun 27, 2012

removeUserAction is not the route responsible to delete a user, but the route responsible to display a form to the browser to allow deleting it (as a browser cannot have a direct link to a DELETE action). If your API is only meant for real HTTP clients, you don't need this action at all.
The DELETE action is deleteUserAction.

lsmith77 closed this Jun 27, 2012

javiern commented Jun 27, 2012

i think i dont make myself clear.... this way of doing thinks is NOT RESTful,

you guys are using a NOT RESTful way in the server to save a client specific incompatibility,

the rest way to make the cliente compatible with the post method is using code on demand,

for example, if you are asumming this is going to be reendered in a browser, the broser will ask for an html representation, in wich it will be an html form, and the broser will support javascript (all modern brosers do that) then u can send some javascript to capture the form whe its ready for submission and use the correct method, with for example xmlhttprequest.

its my way of seeing things,

Owner

lsmith77 commented Jun 27, 2012

i am not entirely happy with the implementation either .. but its not as simple .. see #144 and linked issues.

javiern commented Jun 27, 2012

ok... i think you already passed for this discussion, i'm looked a little bit, i will read it all. for now i have to say that im do not agree with this comment

#69 (comment)

nouns are nouns and verbs are verbs. and as far as i know, edit is a verb and delete is a verb (new is not a verb... but in context it means make a new resource, so its used like verb).

i will keep reading and if i get some ideas i will share them.

Thanks for the answer and the good work, i really like this bundle!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment