[99s-extend] I need your feedback about this cowboy_rest handler.

Stéphane Wirtel stephane at wirtel.be
Wed Aug 27 15:26:11 CEST 2014


On 27 Aug 2014, at 12:53, Loïc Hoguin wrote:

>>>> * for PUT, how I have a 201? I have read the rest_flowchart and I 
>>>> need
>>>> to specify the location header ok, but where? in the is_conflict
>>>> function?
>>>
>>> Why do you need a 201? If you PUT a collection to /:collection then
>>> this is already the location of the collection. I am not sure what 
>>> you
>>> are trying to do there exactly?
>> In this case, the PUT method is used for the creation of the resource
>> and not for the update. This is the reason of the 201 status code.
>>
>> In the rest_flowchart graph for the PUT/POST methods, what is the 
>> node
>> "new resource" ? Is it just the {true, Req, State} from the callback
>> defined in the content_types_accepted?
>>
>> PS: I retested and now, I have my 201 with PUT, just resource_exists 
>> has
>> to return false and not true ;-)
>
> My bad I was a little confusing in my previous answer. You are right, 
> if the resource doesn't exist and PUT is used we get a 201 
> automatically. The location header must only be provided if the 
> resource was created elsewhere.

Don't worry and thank you for your answers.

Stephane

--
Stéphane Wirtel - http://wirtel.be - @matrixise


More information about the Extend mailing list