From ae0dd616737d8e1116de4a04be0bc84188997eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 10 Aug 2016 11:49:31 +0200 Subject: Add tests for responses and request body reading This is a large commit. The cowboy_req interface has largely changed, and will change a little more. It's possible that some examples or tests have not been converted to the new interface yet. The documentation has not yet been updated. All of this will be fixed in smaller subsequent commits. Gotta start somewhere... --- examples/rest_pastebin/src/toppage_handler.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/rest_pastebin/src/toppage_handler.erl b/examples/rest_pastebin/src/toppage_handler.erl index 324fa4a..86bafb7 100644 --- a/examples/rest_pastebin/src/toppage_handler.erl +++ b/examples/rest_pastebin/src/toppage_handler.erl @@ -16,7 +16,6 @@ -export([paste_text/2]). init(Req, Opts) -> - random:seed(os:timestamp()), {cowboy_rest, Req, Opts}. allowed_methods(Req, State) -> @@ -87,13 +86,13 @@ valid_path(<<$/, _T/binary>>) -> false; valid_path(<<_Char, T/binary>>) -> valid_path(T). new_paste_id() -> - Initial = random:uniform(62) - 1, + Initial = rand:uniform(62) - 1, new_paste_id(<>, 7). new_paste_id(Bin, 0) -> Chars = <<"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890">>, << <<(binary_part(Chars, B, 1))/binary>> || <> <= Bin >>; new_paste_id(Bin, Rem) -> - Next = random:uniform(62) - 1, + Next = rand:uniform(62) - 1, new_paste_id(<>, Rem - 1). format_html(Paste, plain) -> -- cgit v1.2.3