Typically, with a stream, you'd just write the HTTP headers, and then just start writing out your content. I don't understand why it's so challenging with Mojolicious. I figured finalizing the response headers would be what I needed, but now I have no idea.I'm not trying to do anything fancy. I'm just trying to read records from a database, and write them out to in a stream to the browser. I would think many people would have this same use case without doing anything too complicated in their web framework.
Thanks for your reply, Sebastian.
After I sent my email, I figured that the drain callback must be the only way. I just had to brush off the Node.js memories and then it all made enough sense. I think it was just confusing because a lot of Mojolicious code can be written in a direct style without needing to use continuation passing, and the documentation didn’t quite make the drain event requirement clear to me, although it all makes more sense in hindsight.
We’re in a slow process of trying to move the 20 year old Koha project away from CGI, so originally I was going to do a bare bones PSGI handler, but we’re starting to use Mojolicious for new parts of the project, so I thought I’d try that instead. While the continuation passing style might not be intuitive, it’ll be much nicer to have an asynchronous Mojolicious handler, so that one request for a large stream of data doesn’t totally tie up the backend server processes. I’m excited to play with Mojolicious more.
And thanks for mentioning the async/await. That looks like a much more user-friendly alternative, although I think that we’ll wait until Mojo::Base doesn’t flag it as experimental. We also have a long tail of older Perl versions to support, unfortunately.
72/330 Wattle St
Ultimo, NSW 2007
Office: 02 9212 0899
Online: 02 8005 0595
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/c4412264-2954-4f5b-a0ed-45f506d53df4n%40googlegroups.com.