Object
# File lib/journey/router.rb, line 53 53: def call env 54: env['PATH_INFO'] = Utils.normalize_path env['PATH_INFO'] 55: 56: find_routes(env).each do |match, parameters, route| 57: script_name, path_info, set_params = env.values_at('SCRIPT_NAME', 58: 'PATH_INFO', 59: @params_key) 60: 61: unless route.path.anchored 62: env['SCRIPT_NAME'] = (script_name.to_s + match.to_s).chomp('/') 63: env['PATH_INFO'] = Utils.normalize_path(match.post_match) 64: end 65: 66: env[@params_key] = (set_params || {}).merge parameters 67: 68: status, headers, body = route.app.call(env) 69: 70: if 'pass' == headers['X-Cascade'] 71: env['SCRIPT_NAME'] = script_name 72: env['PATH_INFO'] = path_info 73: env[@params_key] = set_params 74: next 75: end 76: 77: return [status, headers, body] 78: end 79: 80: return [404, {'X-Cascade' => 'pass'}, ['Not Found']] 81: end
# File lib/journey/router.rb, line 83 83: def recognize req 84: find_routes(req.env).each do |match, parameters, route| 85: unless route.path.anchored 86: req.env['SCRIPT_NAME'] = match.to_s 87: req.env['PATH_INFO'] = match.post_match.sub(/^([^\/])/, '/\1') 88: end 89: 90: yield(route, nil, parameters) 91: end 92: end
# File lib/journey/router.rb, line 107 107: def ast 108: routes.ast 109: end
# File lib/journey/router.rb, line 115 115: def custom_routes 116: partitioned_routes.last 117: end
# File lib/journey/router.rb, line 119 119: def filter_routes path 120: return [] unless ast 121: data = simulator.match(path) 122: data ? data.memos : [] 123: end
# File lib/journey/router.rb, line 125 125: def find_routes env 126: req = request_class.new env 127: 128: routes = filter_routes(req.path_info) + custom_routes.find_all { |r| 129: r.path.match(req.path_info) 130: } 131: 132: routes.sort_by(&:precedence).find_all { |r| 133: r.constraints.all? { |k,v| v === req.send(k) } && 134: r.verb === req.request_method 135: }.reject { |r| req.ip && !(r.ip === req.ip) }.map { |r| 136: match_data = r.path.match(req.path_info) 137: match_names = match_data.names.map { |n| n.to_sym } 138: match_values = match_data.captures.map { |v| v && Utils.unescape_uri(v) } 139: info = Hash[match_names.zip(match_values).find_all { |_,y| y }] 140: 141: [match_data, r.defaults.merge(info), r] 142: } 143: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.