mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Fix rest_pastebin example
Bring the rest_pastebin example in line with REST API changes for creating resources.
This commit is contained in:
parent
b58a0549e1
commit
4e29a49472
1 changed files with 3 additions and 3 deletions
|
@ -46,12 +46,12 @@ resource_exists(Req, _State) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
create_paste(Req, State) ->
|
create_paste(Req, State) ->
|
||||||
{<<$/, PasteID/binary>>, Req2} = cowboy_req:meta(put_path, Req),
|
PasteID = new_paste_id(),
|
||||||
{ok, [{<<"paste">>, Paste}], Req3} = cowboy_req:body_qs(Req2),
|
{ok, [{<<"paste">>, Paste}], Req3} = cowboy_req:body_qs(Req),
|
||||||
ok = file:write_file(full_path(PasteID), Paste),
|
ok = file:write_file(full_path(PasteID), Paste),
|
||||||
case cowboy_req:method(Req3) of
|
case cowboy_req:method(Req3) of
|
||||||
{<<"POST">>, Req4} ->
|
{<<"POST">>, Req4} ->
|
||||||
{<<$/, (new_paste_id())/binary>>, Req4, State};
|
{<<$/, PasteID/binary>>, Req4, State};
|
||||||
{_, Req4} ->
|
{_, Req4} ->
|
||||||
{true, Req4, State}
|
{true, Req4, State}
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue