Can HypermediaResource create PUT/POST/DELETE links?

23 weergaven
Naar het eerste ongelezen bericht

konata

ongelezen,
30 dec 2010, 12:58:2230-12-2010
aan caelum-vraptor-en
Hi,

Can HypermediaResource create PUT/POST/DELETE links? Scenario is
shopping cart, is it possible for HypermediaResource to generate
links, other than GET, that will also include payload with, let say,
cart Id and item Id?

Thanks,
Konata

Lucas Cavalcanti

ongelezen,
30 dec 2010, 13:13:4230-12-2010
aan caelum-v...@googlegroups.com
Hi,

HypermediaResource creates links, but it doesn't mean that you must do a GET on these links.
The http verb depends on what you want to do with the resource.

for example, a shopping cart representation may provide a "payment" link. If you want to create a payment,
you should POST on "payment" link. If you want to see the payments you should GET "payment" link.
If you have a link for each item on the cart, and you want to remove an item from the cart, you should DELETE
on the item's link, and so on.

the links must represent resources, not operations. Choosing the right operation is up to the client.

Regards,
Lucas

Guilherme Silveira

ongelezen,
30 dec 2010, 14:43:5130-12-2010
aan caelum-v...@googlegroups.com
Hello Konata,

As Lucas suggested, links are one of the two hypermedia controls
available. When looking at a rel, the client should decide if he wants
to post/get/delete/and so on to that URI, its his decision (which, by
default is GET).

Because relations are not transitions, if one wants to *act* upon a
resource, he will probably do a put/post/delete/patch at one of its
links.

There is another question that arrives: if you want to know what you
need to post to an URI to create a payment. How to get to know it? In
those cases, the server can provide a hypermedia form instead of a
link. The client is able to fill in the form and send it, using the
verb that it desires. Those are the two concepts of hypermedia
controls that exist in html that can be easily brought to json and
xml.

If you are not looking for a form, but just for a link to an "action",
then try to rethink the relation model again: we are supposed to model
resources, not actions.

If you need give us the example and we try to help you modelling it
into resource links.

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

On Thu, Dec 30, 2010 at 4:13 PM, Lucas Cavalcanti
<lucasm...@gmail.com> wrote:
> Hi,
> HypermediaResource creates links, but it doesn't mean that you must do a GET
> on these links.
> The http verb depends on what you want to do with the resource.
> for example, a shopping cart representation may provide a "payment" link. If
> you want to create a payment,
> you should POST on "payment" link. If you want to see the payments you
> should GET "payment" link.
> If you have a link for each item on the cart, and you want to remove an item
> from the cart, you should DELETE
> on the item's link, and so on.
> the links must represent resources, not operations. Choosing the right
> operation is up to the client.
> Regards,
> Lucas

Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten