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:
parent
630a805541
commit
7a7e144a0d
8 changed files with 42 additions and 39 deletions
|
@ -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}) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue