How to set status code in REST POST in cowboy-Collection of common programming errors
How can I set status code in my REST POST resource.
Now I’m doing this
make_post(Req, State) ->
lager:info("post"),
Resp = cowboy_req:set_resp_body(, Req),
{ok, Resp3} = cowboy_req:reply(201, Resp),
{true, Resp3, State}.
But I receive such errors:
1:43:10.510 [info] [nonode@nohost#pbshare_logic_registration#] [handle_info#35] :Exit Logic from Reason: {function_clause,[{cowboy_req,reply,[204,[],,{http_req,#Port,ranch_tcp,keepalive,,,’HTTP/1.1′,{{127,0,0,1},50024},,undefined,8080,,[],,undefined,[],[{,},{,},{,>},{,},{,}],[{,14},{,undefined},{,14},{,{,,[]}},{,undefined},{,undefined},{,undefined},{,undefined},{,[{{>,>,[]},1000,[]}]}],undefined,[{charset,undefined},{media_type,{,,[]}}],done,undefined,,false,done,[],,undefined}],[{file,”src/cowboy_req.erl”},{line,948}]},{cowboy_rest,respond,3,[{file,”src/cowboy_rest.erl”},{line,1085}]},{cowboy_rest,upgrade,4,[{file,”src/cowboy_rest.erl”},{line,75}]},{cowboy_protocol,execute,4,[{file,”src/cowboy_protocol.erl”},{line,523}]}]} 21:43:10.510 [error] [Undefined#Undefined#emulator] [Undefined#Undefined] :Error in process with exit value: {function_clause,[{cowboy_req,reply,[204,[],,{http_req,#Port,ranch_tcp,keepalive,,,’HTTP/1.1′,{{127,0,0,1},50024},,undefined,8080,,[],,undefined,[],[{,},{,},{,},{,},{,}],[{,14},{,undefined},{,14},{,{,,[]}},{,undefined},{,undefined},{,undefined},{,undefined…
It seems that cowboy tries to send response once again after my reply. But I didn’t any other method in API which can change status code.