aboutsummaryrefslogtreecommitdiffstats
path: root/examples/rest_stream_response/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/rest_stream_response/src')
-rw-r--r--examples/rest_stream_response/src/rest_stream_response.erl15
-rw-r--r--examples/rest_stream_response/src/rest_stream_response_app.erl3
-rw-r--r--examples/rest_stream_response/src/toppage_handler.erl3
3 files changed, 3 insertions, 18 deletions
diff --git a/examples/rest_stream_response/src/rest_stream_response.erl b/examples/rest_stream_response/src/rest_stream_response.erl
deleted file mode 100644
index 31e9a36..0000000
--- a/examples/rest_stream_response/src/rest_stream_response.erl
+++ /dev/null
@@ -1,15 +0,0 @@
-%% Feel free to use, reuse and abuse the code in this file.
-
--module(rest_stream_response).
-
-%% API.
--export([start/0]).
-
-%% API.
-
-start() ->
- ok = application:start(crypto),
- ok = application:start(cowlib),
- ok = application:start(ranch),
- ok = application:start(cowboy),
- ok = application:start(rest_stream_response).
diff --git a/examples/rest_stream_response/src/rest_stream_response_app.erl b/examples/rest_stream_response/src/rest_stream_response_app.erl
index a382d29..46857f4 100644
--- a/examples/rest_stream_response/src/rest_stream_response_app.erl
+++ b/examples/rest_stream_response/src/rest_stream_response_app.erl
@@ -26,7 +26,8 @@ start(_Type, _Args) ->
stop(_State) ->
ok.
-generate_rows(_Table, 0) -> ok;
+generate_rows(_Table, 0) ->
+ ok;
generate_rows(Table, N) ->
ets:insert(Table, {key(), val(), val()}),
generate_rows(Table, N - 1).
diff --git a/examples/rest_stream_response/src/toppage_handler.erl b/examples/rest_stream_response/src/toppage_handler.erl
index 5052038..224446a 100644
--- a/examples/rest_stream_response/src/toppage_handler.erl
+++ b/examples/rest_stream_response/src/toppage_handler.erl
@@ -22,12 +22,11 @@ content_types_provided(Req, State) ->
streaming_csv(Req, Table) ->
{N, Req1} = cowboy_req:binding(v1, Req, 1),
MS = [{{'$1', '$2', '$3'}, [{'==', '$2', N}], ['$$']}],
-
{{stream, result_streamer(Table, MS)}, Req1, Table}.
result_streamer(Table, MS) ->
fun (Socket, Transport) ->
- send_records(Socket, Transport, ets:select(Table, MS, 1))
+ send_records(Socket, Transport, ets:select(Table, MS, 1))
end.
send_records(Socket, Transport, {[Rec], Cont}) ->