Sha256: b9b69815e757f30be0204356738bc0fb81615eae621c70c26b934540b500d5ac

Contents?: true

Size: 634 Bytes

Versions: 4

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

module Grape
  module ContentTypes
    extend Util::Registrable

    # 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'
    }.freeze

    class << self
      def content_types_for_settings(settings)
        settings&.inject(:merge!)
      end

      def content_types_for(from_settings)
        from_settings.presence || Grape::ContentTypes::CONTENT_TYPES.merge(default_elements)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-2.1.3 lib/grape/content_types.rb
grape-2.1.2 lib/grape/content_types.rb
grape-2.1.1 lib/grape/content_types.rb
grape-2.1.0 lib/grape/content_types.rb