Sha256: 36703c171d4ba43f783a9ebda7e4cf0871233f664cbe504e8bb65b104c58e0b6

Contents?: true

Size: 506 Bytes

Versions: 9

Compression:

Stored size: 506 Bytes

Contents

module Goliath
  module Rack
    class DefaultResponseFormat
      include Goliath::Rack::AsyncMiddleware

      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
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
goliath-1.0.5 lib/goliath/rack/default_response_format.rb
goliath-1.0.4 lib/goliath/rack/default_response_format.rb
goliath-1.0.3 lib/goliath/rack/default_response_format.rb
goliath-1.0.2 lib/goliath/rack/default_response_format.rb
goliath-1.0.1 lib/goliath/rack/default_response_format.rb
goliath-1.0.0 lib/goliath/rack/default_response_format.rb
goliath-1.0.0.beta.1 lib/goliath/rack/default_response_format.rb
goliath-0.9.4 lib/goliath/rack/default_response_format.rb
goliath-0.9.2 lib/goliath/rack/default_response_format.rb