Class: HttpRouter::Root

Inherits:
Node
  • Object
show all
Defined in:
lib/http_router/root.rb

Instance Attribute Summary

Attributes inherited from Node

#arbitrary_node, #catchall, #linear, #lookup, #request_node, #value, #variable

Instance Method Summary collapse

Methods inherited from Node

#add, #add_arbitrary, #add_request_methods, #add_to_linear, #initialize, #reset!

Constructor Details

This class inherits a constructor from HttpRouter::Node

Instance Method Details

#add_path(path) ⇒ Object



3
4
5
6
# File 'lib/http_router/root.rb', line 3

def add_path(path)
  node = path.parts.inject(self) { |node, part| node.add(part) }
  node
end

#find(request) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/http_router/root.rb', line 8

def find(request)
  path = request.path_info.dup
  parts = router.split(path)
  parts << '' if path[path.size - 1] == ?/
  params = []
  process_response(
    find_on_parts(request, parts, params),
    parts,
    params, 
    request
  )
end