Sha256: 424adf2d000c43166015124db0cbcd9572d97385bb9a8f7bf291d4dc337bab1a

Contents?: true

Size: 543 Bytes

Versions: 11

Compression:

Stored size: 543 Bytes

Contents

require 'yaml'

module Goliath
  module Rack
    module Formatters
      # A YAML formatter.
      #
      # @example
      #   use Goliath::Rack::Formatters::YAML
      class YAML
        include Goliath::Rack::AsyncMiddleware

        def post_process(env, status, headers, body)
          if yaml_response?(headers)
            body = [body.to_yaml]
          end
          [status, headers, body]
        end

        def yaml_response?(headers)
          headers['Content-Type'] =~ %r{^text/yaml}
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
goliath-1.0.7 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.6 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.5 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.4 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.3 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.2 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.1 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.0 lib/goliath/rack/formatters/yaml.rb
goliath-1.0.0.beta.1 lib/goliath/rack/formatters/yaml.rb
goliath-0.9.4 lib/goliath/rack/formatters/yaml.rb
goliath-0.9.2 lib/goliath/rack/formatters/yaml.rb