module Grape::ContentTypes

def content_types_for(from_settings)

def content_types_for(from_settings)
  from_settings.presence || DEFAULTS
end

def media_type(content_type)

parameters, which is the common case.
nil content type. Skips the split (and its allocation) when there are no
(e.g. `'text/html'` for `'text/html; charset=utf-8'`). Returns nil for a
parameters, with surrounding whitespace removed
The media type of a content-type header: the part before any `;`
def media_type(content_type)
  return if content_type.nil?
  base = content_type.include?(';') ? content_type.split(';', 2).first : content_type
  base.strip
end

def mime_types_for(from_settings)

def mime_types_for(from_settings)
  return MIME_TYPES if from_settings == Grape::ContentTypes::DEFAULTS
  from_settings.invert.transform_keys! { |k| media_type(k) }
end