lib/grape/middleware/versioner/accept_version_header.rb in grape-0.13.0 vs lib/grape/middleware/versioner/accept_version_header.rb in grape-0.14.0

- old
+ new

@@ -25,17 +25,15 @@ if potential_version.empty? throw :error, status: 406, headers: error_headers, message: 'Accept-Version header must be set.' end end - unless potential_version.empty? - # If the requested version is not supported: - unless versions.any? { |v| v.to_s == potential_version } - throw :error, status: 406, headers: error_headers, message: 'The requested version is not supported.' - end + return if potential_version.empty? - env['api.version'] = potential_version - end + # If the requested version is not supported: + throw :error, status: 406, headers: error_headers, message: 'The requested version is not supported.' unless versions.any? { |v| v.to_s == potential_version } + + env[Grape::Env::API_VERSION] = potential_version end private def versions