[99s-extend] Prevent resource creation on POST

Loïc Hoguin essen at ninenines.eu
Sun Oct 5 09:49:00 CEST 2014


If resource_exists = true, then POST doesn't create but update the 
resource at the given URI. If what you are doing is something like 
write-once resources then you will have to reject these cases manually 
by returning halt at some point.

On 10/05/2014 05:56 AM, Amol Hatwar wrote:
> Hello,
>
> I was recently tinkering with cowboy_rest and found that there is no way prevent resource creation in a POST request when it already exists. Either that, or I'm probably not doing something right or don't know enough...
>
> Here's what I have running:
> A user tries to signup with a post request. To be successful, the username has to be unique. The resource_exists/2 method responds with proper true and false values by looking at the request body.
>
> Here's what I want done:
> Iff the resource_exists callback returns true, I don't want the AcceptResource callback to run at all. Instead, I want to send a 4XX status and halt. Is there a canonical way of doing this?
>
> Cheers,
>
> AH
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> https://lists.ninenines.eu/listinfo/extend
>

-- 
Loïc Hoguin
http://ninenines.eu


More information about the Extend mailing list