dannykopping/Slim — comment on commit 3fdc30d98d5038ec9520420fa6d81ef9de24b8a7
File:  line 0
By codeguy:

Hmm... the array of data you JSON encoded is still the HTTP response body. So I'd like to keep it in the $body variable. There are several issues currently that prevent Slim from working like this. First, Slim expects the response returned from `call()` to be a string or implement a `process()` method. I do not like how I've made that into an either/or situation. I'd much prefer if the response implemented a common interface so we remove the need to inspect the response before sending it (e.g. see `Slim::run()`).

The other problem is that the `Slim_Http_Response` instance manages its own content-length header based on the bytesize of its `$body`. When you pass in an object rather than a string, it won't know how to determine content length. Perhaps we need to wrap the `Slim_Http_Response` body property into an object that implements an expected interface (much like Sinatra expects the body to answer to `each`).

Then it becomes easy assuming you set the Response object's body to an object that knows how to provide its content and content length. The trick is making this simple and not overly engineered.

Josh