class HttpRouter
def process_destination_path(path, env)
def process_destination_path(path, env) env['padrino.instance'].instance_eval do request.route_obj = path.route @_response_buffer = nil @params ||= {} @params.update(env['router.params']) @block_params = if path.route.is_a?(HttpRouter::RegexRoute) params_list = env['router.request'].extra_env['router.regex_match'].to_a params_list.shift @params[:captures] = params_list params_list else env['router.request'].params end # Provide access to the current controller to the request # Now we can eval route, but because we have "throw halt" we need to be # (en)sure to reset old layout and run controller after filters. old_params = @params parent_layout = @layout successful = false begin filter! :before (path.route.before_filters - self.class.filters[:before]).each { |filter| instance_eval(&filter)} if path.route.before_filters # If present set current controller layout @layout = path.route.use_layout if path.route.use_layout @route = path.route @route.custom_conditions.each { |blk| pass if instance_eval(&blk) == false } if @route.custom_conditions @block_params = @block_params.slice(0, path.route.dest.arity) if path.route.dest.arity > 0 halt_response = catch(:halt) { route_eval(&path.route.dest) } @_response_buffer = halt_response.is_a?(Array) ? halt_response.last : halt_response successful = true halt @_response_buffer ensure (@_pending_after_filters ||= []).concat(path.route.after_filters) if path.route.after_filters && successful @layout = parent_layout @params = old_params end end end