Module: Grape::ContentTypes

Extended by:
Util::Registrable
Defined in:
lib/grape/content_types.rb

Constant Summary collapse

CONTENT_TYPES =

Content types are listed in order of preference.

{
  xml: 'application/xml',
  serializable_hash: 'application/json',
  json: 'application/json',
  binary: 'application/octet-stream',
  txt: 'text/plain'
}.freeze

Class Method Summary collapse

Methods included from Util::Registrable

default_elements, register

Class Method Details

.content_types_for(from_settings) ⇒ Object



23
24
25
# File 'lib/grape/content_types.rb', line 23

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

.content_types_for_settings(settings) ⇒ Object



19
20
21
# File 'lib/grape/content_types.rb', line 19

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