chicagoboss

Need an use case example for stream response in ChicagoBoss


ChicageBoss controller API has this

{stream, Generator::function(), Acc0}

Stream a response to the client using HTTP chunked encoding. For each chunk, the Generator function is passed an accumulator (initally Acc0) and should return either {output, Data, Acc1} or done.

I am wondering what is the use case for this? There are others like Json, output. When will this stream be useful?

Can someone present an use case in real world?


Solution

  • Serving large files for download might be the most straight-forward use case.

    You could argue that there are also other ways to serve files so that users can download them, but these might have other disadvantages: