Sha256: aed114b74d1c1aa3f8fe43bc6ed9d5f6d2231f9372baffce6dfc2df88c31e878

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

require 'grape/util/registrable'

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

2 entries across 2 versions & 1 rubygems

Version Path
grape-2.0.0 lib/grape/content_types.rb
grape-1.8.0 lib/grape/content_types.rb