根据http://www.sinatrarb.com/intro.html#Request/Instance%20Scope
您有请求范围绑定:
是否有任何捷径可以完全相同,尽管有方法?
get // do
# do something
end
post // do
# do something exactly the same as previous
end
put // do
# do something exactly the same as previous
end
delete // do
# do something exactly the same as previous
end
...
答案 0 :(得分:3)
不确定我是否理解你。但我认为你会同时捕获多个http动词,为此你可以使用multi route
示例强>
require 'sinatra'
require "sinatra/multi_route"
route :get, :post, '/foo' do
# "GET" or "POST"
p request.env["REQUEST_METHOD"]
end
# Or for module-style applications
class MyApp < Sinatra::Base
register Sinatra::MultiRoute
route :get, :post, '/foo' do
# ...
end
end