module ActionDispatch::Http::MimeNegotiation

def negotiate_mime(order)

Returns the first MIME type that matches the provided array of MIME types.
def negotiate_mime(order)
  formats.each do |priority|
    if priority == Mime::ALL
      return order.first
    elsif order.include?(priority)
      return priority
    end
  end
  order.include?(Mime::ALL) ? format : nil
end