From 7a7e144a0d79767f726ca9988a7b8fc752f998ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 8 Sep 2013 19:50:31 +0200 Subject: Convert the REST streaming example to a release --- .../rest_stream_response/src/rest_stream_response.erl | 15 --------------- .../rest_stream_response/src/rest_stream_response_app.erl | 3 ++- examples/rest_stream_response/src/toppage_handler.erl | 3 +-- 3 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 examples/rest_stream_response/src/rest_stream_response.erl (limited to 'examples/rest_stream_response/src') 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}) -> -- cgit v1.2.3