users@jersey.java.net

Re: Adding a resource - HTTP POST

From: Nam Nguyen <Nam.Nguyen_at_Sun.COM>
Date: Tue, 23 Oct 2007 16:33:40 -0700

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?

Unless there are more use cases for @ReturnCode , I would prefer to
avoid it as a solution.

-Nam