diff options
author | Loïc Hoguin <[email protected]> | 2013-09-08 19:50:31 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-09-08 19:50:31 +0200 |
commit | 7a7e144a0d79767f726ca9988a7b8fc752f998ae (patch) | |
tree | ae98a1cd8825841b6b4b134d0e7cf9fdc2945270 /examples/rest_stream_response/src | |
parent | 630a8055412bb9622ca202ffb7008d418df78d5c (diff) | |
download | cowboy-7a7e144a0d79767f726ca9988a7b8fc752f998ae.tar.gz cowboy-7a7e144a0d79767f726ca9988a7b8fc752f998ae.tar.bz2 cowboy-7a7e144a0d79767f726ca9988a7b8fc752f998ae.zip |
Convert the REST streaming example to a release
Diffstat (limited to 'examples/rest_stream_response/src')
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}) -> |