Sha256: c13390a084cfc6d4a6238056ce23b8e2fbb7a83e95a8771da10a6abaecc4ec84

Contents?: true

Size: 643 Bytes

Versions: 4

Compression:

Stored size: 643 Bytes

Contents

module Grape
  module ContentTypes
    # Content types are listed in order of preference.
    CONTENT_TYPES = {
      xml: 'application/xml',
      serializable_hash: 'application/json',
      json: 'application/json',
      binary: 'application/octet-stream',
      txt: 'text/plain'
    }

    def self.content_types_for_settings(settings)
      return if settings.blank?

      settings.each_with_object({}) { |value, result| result.merge!(value) }
    end

    def self.content_types_for(from_settings)
      if from_settings.present?
        from_settings
      else
        Grape::ContentTypes::CONTENT_TYPES
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-0.16.2 lib/grape/util/content_types.rb
grape-0.16.1 lib/grape/util/content_types.rb
grape-0.15.0 lib/grape/util/content_types.rb
grape-0.14.0 lib/grape/util/content_types.rb