class Sinatra::Base
def dispatch!
def dispatch! self.class.filters.each do |block| res = catch(:halt) { instance_eval(&block) ; :continue } return unless res == :continue end if routes = self.class.routes[@request.request_method] path = @request.path_info original_params = nested_params(@request.params) routes.each do |pattern, keys, conditions, method_name| if pattern =~ path values = $~.captures.map{|val| val && unescape(val) } params = if keys.any? keys.zip(values).inject({}) do |hash,(k,v)| if k == 'splat' (hash[k] ||= []) << v else hash[k] = v end hash end elsif values.any? {'captures' => values} else {} end @params = original_params.merge(params) catch(:pass) { conditions.each { |cond| throw :pass if instance_eval(&cond) == false } return invoke(method_name) } end end end raise NotFound end