For all the REST fans out there, I have two questions.
Usually when we think of RESTful urls, we think in terms of rather
simple struct-like objects. The canonical example is using
ActiveResource to create person objects:
We expect to get back a 201 response with the url to the newly-created
resource, like /people/47. If I GET /people/47, I should see the
exact same data as when I created it.
My first question is, what if this is not a symmetrical operation?
For example, let’s say I want to transmit a pizza order:
Here I’m ordering combo #3, which is a actually a large pepperoni, a 6-
pack of root beer, and a slice of tiramisu. The server responds with
a 201 to /orders/342.
But if I do a GET /orders/342, I might see this:342 Jeff 555-555-1212 1 18" Pepperoni 1 2 Root Beer 6 1 Tiramisu 1
Is this kind of thing acceptable in the REST world? I hope so,
because having the client create each step of the hierarchy would be a
pain (first create an empty order, then create each line item, etc.)
My second question is, how would I create the pizza order using
ActiveResource? In other words, do I need to worry that the
attributes that I use for the create action are not the same as the
attributes I’ll be receiving?