[erlang-questions] Rest endpoint behaving strangely

Loïc Hoguin essen@REDACTED
Tue Mar 1 12:52:23 CET 2016


See 
http://ninenines.eu/docs/en/cowboy/1.0/guide/rest_flowcharts/#put,_post_and_patch_methods 
for details as to why you get a status code instead of another.

I'm not entirely sure the diagram is clear enough though. What status 
code is returned depends on what you return from the callback, what 
method it is, whether there's a body in the response and whether the 
resource existed previously. The diagram is at least missing the case 
where the resource didn't exist and the method is PUT, where you get a 201.

On 03/01/2016 12:38 PM, Pavanan M S wrote:
> Sorry the response code is *303 not 302*
>
> On 1 March 2016 at 15:46, Loïc Hoguin <essen@REDACTED
> <mailto:essen@REDACTED>> wrote:
>
>     I think you didn't say which server you are using. Not Cowboy
>     considering the 404 you get.
>
>     On 03/01/2016 08:57 AM, Pavanan M S wrote:
>
>         Hi all,
>                    I created a few rest end points for an app and it
>         works. Now I
>         am starting to write the test cases. But there is a strange
>         issue in my
>         code.
>
>                   When I connect the rest client with url  "
>         http://localhost:8080/[resource_name]
>         <http://localhost:8080/%5Bresource_name%5D> " it works perfectly.
>
>                   But if I use " http://localhost:8080/[resource_name]*/
>         <http://localhost:8080/%5Bresource_name%5D*/> *" , (A
>         slash ( '/' ) in the end) it gives a 404.
>
>                   Now that I am trying to write test cases using common
>         test, I
>         just tried to make requests using ibrowse first. And there I found
>         something strange again.
>
>                   When I used ibrowse to issue a post request, it
>         returned 302,
>         with the location of the resource. In the browser I am getting
>         200, I
>         guess because of get.
>
>                    Now, since get is working, I guess the resource is being
>         created, Then what might be the reason that I am not getting 201
>         ? Also,
>         Is this related to the above problem ?
>                   Please help.
>
>
>         _______________________________________________
>         erlang-questions mailing list
>         erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>         http://erlang.org/mailman/listinfo/erlang-questions
>
>
>     --
>     Loïc Hoguin
>     http://ninenines.eu
>     Author of The Erlanger Playbook,
>     A book about software development using Erlang
>
>

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang



More information about the erlang-questions mailing list