<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hi all, </span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I am learning cowboy by building a small application with rest interface. </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
I have a hello_world rest handler and I want to implement POST method that returns  </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">json as response to a client. Therefor I implemented  callbacks allowed_methods, </div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">content_types_accepted and hello_json. The docu says user callbacks can </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
return {Value, Req, State} and also can return {halt, Req, State}. It is not really clear </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">what that Value should be. So I tried {ok, Req, State} and {true, Req, State} and with</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">both values I have </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div>=ERROR REPORT==== 11-May-2013::16:06:40 ===</div><div>Error in process <0.6649.0> with exit value: {function_clause,[{cowboy_req,reply,[303,....</div>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
and client gets right response. If I use {halt, Req, State} the client gets right response too</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">and there is no errors. So, Is it right way to write a POST callback and what Values can</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">be used for user callbacks? I write my code below.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">amike, </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Vitali</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<div>allowed_methods(Req, State) -></div><div><span style="white-space:pre-wrap">  </span>{[<<"POST">>, <<"DELETE">>], Req, State}.</div><div><br></div><div>content_types_accepted(Req, State) -></div>
<div><span style="white-space:pre-wrap">  </span>{[</div><div><span style="white-space:pre-wrap">       </span>    {{<<"application">>, <<"x-www-form-urlencoded">>, []}, hello_json}</div>
<div><span style="white-space:pre-wrap">  </span> ], Req, State}.</div><div><br></div><div>hello_json(Req, State) -></div><div><span style="white-space:pre-wrap">     </span>{ok, Req2} = cowboy_req:reply(200, [{<<"content-type">>, <<"application/json">>} ], <<"{\"rest\": \"Hello World!\"}">>, Req),</div>
<div><span style="white-space:pre-wrap">  </span>{halt, Req2, State}.</div></div>