class AllButPattern
Match = Struct.new(:captures) # :captures鍵中存放的就是捕獲的匹配文本
def initialize(except)
@except = except
@captures = Match.new([])
end
def match(str)
@captures unless @except === str
end
end
def all_but(pattern)
AllButPattern.new(pattern)
end
get all_but("/index") do
# ...
end
上面的例子可能太繁瑣了,因?yàn)樗部梢杂酶唵蔚姆绞奖硎觯?/p>
get // do
pass if request.path_info == "/index"
# ...
end
更多建議: