On Tue, October 23, 2007 19:33, Nam Nguyen wrote:
> Florian Rosenberg wrote:
>> On Tue, October 23, 2007 17:27, Marc Hadley wrote:
>>
>>> On Oct 23, 2007, at 3:15 PM, Nam Nguyen wrote:
>>>
>>>> You need to have the method return Response and use
>>>> Response.Builder.created(uri) as return value.
>>>>
>>>>
>>> Right. A 204 status is the default for a method that returns void, to
>>> get another status you need to return an instance of Response and
>>> Response.Builder provides an easy way to create one.
>>>
>>
>> Thanks a lot, works fine.
>>
>> I would also be cool to have an annotation for return codes. Foe
>> example:
>> @ReturnCode(success="204", failure="500"), it would allow to leave the
>> method signature of a (delete) operation unchanged and get the desired
>> return code in case of a successful execution of an operation and an
>> internal exception.
>>
>> Opinions?
>>
> If the most commonly expected response for POST is 'Created' why can't
> we make it the default response without requiring an explicit Response
> return value?
I don't say that 201 "Created" should be the default. I looked at the HTTP
RFC and thought that this is the one I would like to have as a response.
And I found out during the unit test that it is not the case ;). Other
people might have a different one, such as 200 or whatsoever.
> Unless there are more use cases for @ReturnCode , I would prefer to
> avoid it as a solution.
I guess @ReturnCode would be useful for more people, it makes the ROA
design much more flexible by customizing the return code that complies
with the different design options people will have (as soon as more people
jump on REST).
-Florian