[99s-extend] Prevent resource creation on POST

Amol Hatwar amol at hatwar.org
Sun Oct 5 04:56:58 CEST 2014


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


More information about the Extend mailing list