Re:Strata Web Framework
by mjijackson on Wednesday September 21, 2011 @01:09PM
(#3022818)
The Strata spec states that a body may be either a string or a stream. All Strata middleware that needs to modify the body in some way must account for this. It's not difficult to do a "if (typeof body == 'string')".
Strata borrows many concepts from Rack, but not the synchronous part. Instead of expecting your app to return something, Strata gives you a callback that you can use to serve the response when you're ready.
I admit the manual could probably give a better example of streaming a response. For now, check out the static file serving middleware (https://github.com/mjijackson/strata/tree/master/lib/static....). You'll see that the response body is simply a readable stream to the file on disk.
Strata borrows many concepts from Rack, but not the synchronous part. Instead of expecting your app to return something, Strata gives you a callback that you can use to serve the response when you're ready.
I admit the manual could probably give a better example of streaming a response. For now, check out the static file serving middleware (https://github.com/mjijackson/strata/tree/master/lib/static....). You'll see that the response body is simply a readable stream to the file on disk.