aboutsummaryrefslogtreecommitdiffstats
path: root/examples/rest_pastebin/src/toppage_handler.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-04-12 19:49:35 +0200
committerLoïc Hoguin <[email protected]>2013-04-12 19:49:35 +0200
commit5755d1155f4578419a301abb33aa7bac30020d97 (patch)
tree2841b6812cbc9d3252c310e01779eebad3c3c7dc /examples/rest_pastebin/src/toppage_handler.erl
parentb58a0549e139b410db50ddd443cc457fb677fa7e (diff)
parent4e29a4947283033ac08835387fd5d98b8aee85a4 (diff)
downloadcowboy-5755d1155f4578419a301abb33aa7bac30020d97.tar.gz
cowboy-5755d1155f4578419a301abb33aa7bac30020d97.tar.bz2
cowboy-5755d1155f4578419a301abb33aa7bac30020d97.zip
Merge branch 'fix_pastebin_example' of git://github.com/acammack/cowboy
Diffstat (limited to 'examples/rest_pastebin/src/toppage_handler.erl')
-rw-r--r--examples/rest_pastebin/src/toppage_handler.erl6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/rest_pastebin/src/toppage_handler.erl b/examples/rest_pastebin/src/toppage_handler.erl
index a6a0829..9267349 100644
--- a/examples/rest_pastebin/src/toppage_handler.erl
+++ b/examples/rest_pastebin/src/toppage_handler.erl
@@ -46,12 +46,12 @@ resource_exists(Req, _State) ->
end.
create_paste(Req, State) ->
- {<<$/, PasteID/binary>>, Req2} = cowboy_req:meta(put_path, Req),
- {ok, [{<<"paste">>, Paste}], Req3} = cowboy_req:body_qs(Req2),
+ PasteID = new_paste_id(),
+ {ok, [{<<"paste">>, Paste}], Req3} = cowboy_req:body_qs(Req),
ok = file:write_file(full_path(PasteID), Paste),
case cowboy_req:method(Req3) of
{<<"POST">>, Req4} ->
- {<<$/, (new_paste_id())/binary>>, Req4, State};
+ {<<$/, PasteID/binary>>, Req4, State};
{_, Req4} ->
{true, Req4, State}
end.