class Grape::Middleware::Versioner::AcceptVersionHeader
route.
X-Cascade header to alert Grape::Router to attempt the next matched
If version does not match this route, then a 406 is raised with<br><br>env => ‘v1’
The following rack env variables are set:
Accept-Version: v1
Example: For request header
based on the HTTP Accept-Version header
This middleware sets various version related rack environment variables
def before
def before potential_version = env[Grape::Http::Headers::HTTP_ACCEPT_VERSION] potential_version = potential_version.scrub unless potential_version.nil? not_acceptable!('Accept-Version header must be set.') if strict? && potential_version.blank? return if potential_version.blank? not_acceptable!('The requested version is not supported.') unless potential_version_match?(potential_version) env[Grape::Env::API_VERSION] = potential_version end
def not_acceptable!(message)
def not_acceptable!(message) throw :error, status: 406, headers: error_headers, message: message end