10: def run(env)
11: controller, action, args = :home, :index, nil
12: query_string = env['QUERY_STRING']||''
13: params = parse_query_string(query_string)
14: req_path = env['PATH_INFO'].gsub(/\/+/, '/')
15: case req_path
16: when '/'
17:
18: when /^\/?([-a-zA-Z]+)\/?$/
19: controller = $1
20: when /^\/?([-a-zA-Z]+)\/([-a-zA-Z]+)\/?(.*)?$/
21: controller = $1
22: action = $2
23: args = $3
24: else
25: controller = :error
26: args = req_path
27: end
28: controller_vars = {
29: :params => params,
30: :req_path => req_path,
31: :query_string => query_string,
32: }
33: delegate(controller, action, args, controller_vars)
34: end