[99s-extend] I need your feedback about this cowboy_rest handler.
Paulo F. Oliveira
paulo.ferraz.oliveira at gmail.com
Sat Aug 30 00:15:56 CEST 2014
PUT _should_ (there is no police here though) be used to either create
a resource or completely update it (it's refered to as "upsert" by
some; in Redis, for example, a similar concept would be "set").
Partial modifications should be made using PATCH. POST is what is
commonly used to create a resource. According to
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 412 is used
when "[t]he precondition given in one or more of the request-header
fields evaluated to false when it was tested on the server." (also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24).
- Paulo F. Oliveira
On 27 August 2014 14:26, Stéphane Wirtel <stephane at wirtel.be> wrote:
> 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
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> https://lists.ninenines.eu/listinfo/extend
More information about the Extend
mailing list