On Mar 27, 2009, at 9:06 AM, Phil Pirozhkov wrote:
>
> Hi
>
> All over the net you can find claim that rest is bad.
> "Everything you need to do can be done with GET, PUT, POST, and
> DELETE.
> The beauty of REST is that those four verbs are all you need."
> Not true.
> I currently need "get", "put", "update" (post), "delete",
> "undelete", "suspend", "resume"
> i have to add additional parameter :command and REST ends up here.
I'm aware that the rest principles just doesn't work every kind of
software projects (anyway "REST" != get/post/put/delete, if you think
of webdav you'll see that it is rest, what is expanded is the http
protocol itself). And note that here I do not refer to web
applications, but to web services (so the client doesn't needs to be a
web browser --we all know that ie. you just can't use 'delete' as a
form method--).
anyway, you can model all of the methods you listed as separate
resources, ie "undelete" can be a post to a undelete resource with an
identifier of the deleted resource, suspend and resume can be
associated to a resource to post to, which accept the already
mentioned identifier. (yeah, overloaded post here :) )
Sorry, I just don't want to start another useless flame war, I know
that especially for web application it is difficult to model
application states only using resources, and there are cases in which
rest simply doesn't fit.
>
> Not all browsers support that four correctly.
> Pushing "back" after "POST" works ugly in Safari and Firefox.
sorry, didn't got this one xD
>
> You can still have you controller initialized with @method, and
> treat it however you like.
>
> But it's way easier to change the code on client side:
> <form id=list method=delete action=/users/1 ...
>
> to
> <form id=users method=post action="/users/delete/1 ...
indeed :)
>
> than that router mess on server side
>
> Helpers always help:
> #users
> link_to(:user, :id, :delete)
>
> or something similar
>
> and just add a corresponding method to your controller
>
> class Users
> def delete
> user = User.find(@params[:id])
> user.drop()
> end
>
>
> But i'm sure "router" can be easily transformed to conform REST
> (it's currently nine code rows)
I'll have a better look to the code (I'm quite new to reia itself --
even to erlang itself)
>
>
> Cheers, Phil
best,
fz