Class: HttpRouter::Root
Instance Attribute Summary
Attributes inherited from Node
#catchall, #extension_node, #linear, #lookup, #request_node, #value, #variable
Instance Method Summary collapse
Methods inherited from Node
#add, #add_extension, #add_request_methods, #initialize, #reset!
Constructor Details
This class inherits a constructor from HttpRouter::Node
Instance Method Details
#add_path(path) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/http_router/root.rb', line 3 def add_path(path) node = path.parts.inject(self) { |node, part| node.add(part) } if path.extension node = node.add_extension(path.extension) end node end |
#find(request) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/http_router/root.rb', line 11 def find(request) path = request.path_info.dup path.slice!(-1) if router.ignore_trailing_slash? && path[-1] == ?/ extension = extract_extension(path) parts = router.split(path) parts << '' if path[path.size - 1] == ?/ params = [] process_response( find_on_parts(request, parts, extension, params), parts, extension, params, request ) end |