def check_version
accept_header = request.headers['Accept']
mime_types = accept_header.split(%r{,\s*})
version_header = API_VERSION
mime_types.each do |mime_type|
values = mime_type.split(%r{;\s*})
values.each do |value|
value = value.downcase
if value.include?("version")
version_header = value.split("=")[1].delete(' ').to_f
end
end
end
if not version_header
$requested_api_version = API_VERSION
else
$requested_api_version = version_header
end
if not SUPPORTED_API_VERSIONS.include? $requested_api_version
invalid_version = $requested_api_version
$requested_api_version = API_VERSION
return render_format_error(:not_acceptable, "Requested API version #{invalid_version} is not supported. Supported versions are #{SUPPORTED_API_VERSIONS.map{|v| v.to_s}.join(",")}")
end
end