lib/grape/api.rb in grape-0.1.3 vs lib/grape/api.rb in grape-0.1.4
- old
+ new
@@ -60,15 +60,16 @@
# get '/main' do
# {:some => 'data'}
# end
#
# version 'v1' do
- # get '/legacy' do
+ # get '/main' do
# {:legacy => 'data'}
# end
# end
# end
+ #
def version(*new_versions, &block)
new_versions.any? ? nest(block){ set(:version, new_versions) } : settings[:version]
end
# Specify the default format for the API's
@@ -137,13 +138,15 @@
def route(methods, paths, &block)
methods = Array(methods)
paths = ['/'] if paths == []
paths = Array(paths)
endpoint = build_endpoint(&block)
+ options = {}
+ options[:version] = /#{version.join('|')}/ if version
methods.each do |method|
paths.each do |path|
- path = Rack::Mount::Strexp.compile(compile_path(path))
+ path = Rack::Mount::Strexp.compile(compile_path(path), options, ['/'], true)
route_set.add_route(endpoint,
:path_info => path,
:request_method => (method.to_s.upcase unless method == :any)
)
end