class Grape::Middleware::Versioner::Param
env => ‘v1’
‘/resource’:
The following rack env variables are set and path is rewritten to
/resource?apiver=v1
Example: For a uri path
version will be used.
If the version substring is not passed the version (highest mounted)
versions, a 404 error is thrown.
If the version substring does not match any potential initialized
request parameters for subsequent middleware and API.
based on the request parameters and removes that parameter from the
This middleware sets various version related rack environment variables
def before
def before potential_version = Rack::Utils.parse_nested_query(env[Rack::QUERY_STRING])[parameter_key] return if potential_version.blank? version_not_found! unless potential_version_match?(potential_version) env[Grape::Env::API_VERSION] = potential_version env[Rack::RACK_REQUEST_QUERY_HASH].delete(parameter_key) if env.key? Rack::RACK_REQUEST_QUERY_HASH end