Sha256: 933cc0bdbb55c1adcea812c99d04a8f3b707040a4d6993aa0800b01422d3ab27

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

module Grape
  module ContentTypes
    # Content types are listed in order of preference.
    CONTENT_TYPES = { # rubocop:disable Style/MutableConstant
      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

1 entries across 1 versions & 1 rubygems

Version Path
grape-1.3.0 lib/grape/util/content_types.rb