Class: Goliath::Rack::DefaultResponseFormat
- Inherits:
-
Object
- Object
- Goliath::Rack::DefaultResponseFormat
- Includes:
- AsyncMiddleware
- Defined in:
- lib/goliath/rack/default_response_format.rb
Instance Method Summary (collapse)
Methods included from AsyncMiddleware
Constructor Details
This class inherits a constructor from Goliath::Rack::AsyncMiddleware
Instance Method Details
- (Object) post_process(env, status, headers, body)
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/goliath/rack/default_response_format.rb', line 6 def post_process(env, status, headers, body) return [status, headers, body] if body.respond_to?(:to_ary) new_body = [] if body.respond_to?(:each) body.each { |chunk| new_body << chunk } else new_body << body end new_body.collect! { |item| item.to_s } [status, headers, new_body.flatten] end |