Class: Log::Analyzer::Router

Inherits:
ActionDispatch::Journey::Router
  • Object
show all
Defined in:
lib/log-analyzer/router.rb

Instance Method Summary collapse

Instance Method Details

#serve(req) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/log-analyzer/router.rb', line 3

def serve(req)
  find_routes(req).each do |match, parameters, route|
    set_params  = req.path_parameters
    path_info   = req.path_info
    script_name = req.script_name

    unless route.path.anchored
      req.script_name = (script_name.to_s + match.to_s).chomp('/')
      req.path_info = match.post_match
      req.path_info = "/" + req.path_info unless req.path_info.start_with? "/"
    end

    req.path_parameters = set_params.merge parameters
    unless route.app.matches?(req)
      req.script_name     = script_name
      req.path_info       = path_info
      req.path_parameters = set_params
      next
    end

    return route
  end

  nil
end