On 5 May 2010, at 20:51, Luciano Resende wrote:
>>>
>>
>> Looking over the controller code you're right, POST and PUT are actually
>> identical in their behaviour.
>>
>> So the question is whether to (1) not bother with PUT, or (2) make POST and
>> PUT behave in a more typical manner; i.e. POST should throw an exception if
>> the property exists, and PUT should throw an exception if it doesn't.
>
> Just my 0.0002c
>
> Usually POST would create, and then return HTTP Status code of 201
> confirming the resource was created (and might return a location URL
> of the created resource), and possible an exception when the resource
> is already available as Scott mentioned. For PUT, it's expected just
> a HTTP status code of 200. Another aspect is that you could PUT to
> something like {wookie}/properties/propertyName (if propertyName is
> the key to a given property) and that would update the value of that
> specific key. Maybe this can help sort out if there is a need for both
> POST and PUT.
I've had a play with the PropertiesController and its pretty easy to make POST
return either 201 or an exception if the property exists. Likewise for PUT to
return a 404 if the property doesn't exist.
Would this cause any problems though for current implementations? The "create
or update" pattern may not be pure REST but on the other hand its even easier
and more resilient for clients to code to.
>
>
> --
> Luciano Resende
> http://people.apache.org/~lresende
> http://twitter.com/lresende1975
> http://lresende.blogspot.com/