Method: IntegrationApi::ApiClient#select_header_content_type

Defined in:
lib/integration_api/api_client.rb

#select_header_content_type(content_types) ⇒ String

Return Content-Type header based on an array of content types provided.



338
339
340
341
342
343
344
# File 'lib/integration_api/api_client.rb', line 338

def select_header_content_type(content_types)
  # use application/json by default
  return 'application/json' if content_types.nil? || content_types.empty?
  # use JSON when present, otherwise use the first one
  json_content_type = content_types.find { |s| json_mime?(s) }
  json_content_type || content_types.first
end