[99s-extend] Cowboy REST Logic

Loïc Hoguin essen at ninenines.eu
Wed Feb 13 16:34:54 CET 2013


On 02/13/2013 02:52 PM, Phillips, Christopher wrote:
>
>    In 6.1, and still in 8.0, there is some logic that surprised me, and
> I wanted to see if it was intentional, or if I'm missing something.
>
>    If I set up a POST such that it's a create, I get back a 303, rather
> than a 201, on successful create. This came as a bit of a surprise; I
> know from Webmachine, if it's a new resource being created, a POST will
> return a 201 (N11 to P11 in Webmachine's v3 diagram).
>
>    Is this intentional? The logic seems to be post_is_create/2 ->
> create_path/2 -> put_resource/3 -> choose_content_type/5 -> next/3 ->
> respond(_, _, 303). It may be that this is a better response, rather
> than a 201 with the location header, but it came as a surprise given web
> machine's behavior.

This difference is probably not intentional. Please open a ticket. :)

>    For background, I'm attempting to migrate some web machine code to
> Cowboy, which is serving a RESTful API to a Javascript client. The
> client is making CORS calls. Receiving a 303 and a Location header
> seemed to mean that the call was redirected before the client side code
> ever saw it (not sure what the browser was doing; I was expecting
> another request, but I wasn't quite lucid enough to check for that last
> night when working on it); a 201 allows me to examine the location.

Would be interested to know more about your CORS implementation, that's 
something I would like to have in the guide.

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the Extend mailing list