class Rack::App::Router::Tree
Constants
- E
Attributes
root[R]
Public Class Methods
new()
click to toggle source
# File lib/rack/app/router/tree.rb, line 12 def initialize @root = self.class::Branch.new end
Public Instance Methods
add(endpoint)
click to toggle source
# File lib/rack/app/router/tree.rb, line 16 def add(endpoint) @root.set(self.class::Env.new(endpoint)) end
call(env)
click to toggle source
# File lib/rack/app/router/tree.rb, line 20 def call(env) configure_request(env) @root.call(env, *env[Rack::App::Constants::ENV::SPLITTED_PATH_INFO]) end
Protected Instance Methods
configure_request(env)
click to toggle source
# File lib/rack/app/router/tree.rb, line 29 def configure_request(env) env[E::PATH_SEGMENTS_PARAMS] ||= {} env[E::PARAMS] ||= Rack::App::Params.new(env) fpi = format_path_info(env).freeze env[E::FORMATTED_PATH_INFO] = fpi spi = split_path_info(fpi).freeze env[E::SPLITTED_PATH_INFO] = spi env[E::EXTNAME] = extname(spi) end
extname(splitted_path_info)
click to toggle source
# File lib/rack/app/router/tree.rb, line 47 def extname(splitted_path_info) File.extname(splitted_path_info.last) end
format_path_info(env)
click to toggle source
# File lib/rack/app/router/tree.rb, line 39 def format_path_info(env) Rack::App::Utils.normalize_path(env[E::PATH_INFO]) end
split_path_info(formatted_path_info)
click to toggle source
# File lib/rack/app/router/tree.rb, line 43 def split_path_info(formatted_path_info) Rack::App::Utils.split_path_info(formatted_path_info) end