[99s-extend] How to use the PUT verb with Cowboy_Rest ?

Eduardo Gurgel edgurgel at gmail.com
Sun Aug 24 02:25:54 CEST 2014


I think you can always halt the processing and do the reply by yourself:

{ok, Req2} = cowboy_req:reply(412, Req),
{halt, Req2, State}.


On Sun, Aug 24, 2014 at 12:22 PM, Stéphane Wirtel <stephane at wirtel.be>
wrote:

> resource_exists is used by POST
> is_conflict is used by PUT (from the code)
> but in the case where my database already exists, I need to return 412 and
> not 409.
>
> and I know I don't respect the default value returned by Cowboy_rest.
>
>
> On 24 Aug 2014, at 2:16, Daniel Goertzen wrote:
>
>  You should implement the resource_exists() callback; this will let the
>> rest
>> module pick a 200 vs 201.  If the db name was incorrect, I think you are
>> just supposed to return false from the put callback.  I can't remember the
>> http code for that case.
>>
>> Regards,
>> Dan.
>>
>>
>> On Sat, Aug 23, 2014 at 6:58 PM, Stéphane Wirtel <stephane at wirtel.be>
>> wrote:
>>
>>  Hi all,
>>>
>>> 1. I would like to use the cowboy_rest protocol with cowboy 1.0 but I
>>> have
>>> a small crash.
>>>
>>> Here is my code:
>>>
>>> https://www.friendpaste.com/7O3X4fG4u31gBg9MgW5xg4
>>>
>>> Could you tell me if I correctly use cowboy_rest for the PUT verb? I have
>>> seen is_conflict/2, but I don't know how to use it.
>>>
>>> 2. I would like to change the response code, but I get the error. Is it
>>> possible?
>>>
>>> Thank you.
>>>
>>> Regards,
>>>
>>> Stephane
>>>
>>> --
>>> Stéphane Wirtel - http://wirtel.be - @matrixise
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> https://lists.ninenines.eu/listinfo/extend
>>>
>>>
>
> --
> Stéphane Wirtel - http://wirtel.be - @matrixise
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> https://lists.ninenines.eu/listinfo/extend
>



-- 
Eduardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20140824/89d3a7f6/attachment.html>


More information about the Extend mailing list