You could also experiment with a simple rack middleware that just
calls to_json on the upstream response body. Something like
class JsonMiddleware
def initialize(app)
@app = app # Your sinatra app
end
def call(env)
upstream_response = @app.call(env)
upstream_response[2] = upstream_response[2].to_json
upstream_response
end
end
or similar (note the above is completely off the top of my head, so
may not work as is).
I think you can then just call use JsonMiddleware in your sinatra app.
Cheers,
Roland