0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00

Convert the REST streaming example to a release

This commit is contained in:
Loïc Hoguin 2013-09-08 19:50:31 +02:00
parent 630a805541
commit 7a7e144a0d
8 changed files with 42 additions and 39 deletions

View file

@ -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}) ->