lib/plezi/router/route.rb in plezi-0.14.7 vs lib/plezi/router/route.rb in plezi-0.14.8
- old
+ new
@@ -31,17 +31,19 @@
raise 'Controller should be a class object' unless controller.is_a?(Class)
end
end
def call(request, response)
- return nil unless match(request.path_info, request)
+ params = match(request.path_info, request)
+ return nil unless params
c = @controller.new
- c._pl_respond(request, response, Thread.current[@route_id])
+ c._pl_respond(request, response, params)
end
def fits_params(path, request)
params = (Thread.current[@route_id] ||= {}).clear
+ params.default_proc = Plezi.hash_proc_4symstr
params.update request.params.to_h if request && request.params
# puts "cutting: #{path[(@prefix_length)..-1] ? path[(@prefix_length + 1)..-1] : 'nil'}"
pa = (path[@prefix_length..-1] || ''.freeze).split('/'.freeze)
# puts "check param count: #{pa}"
return false unless @params_range.include?(pa.length)
@@ -49,10 +51,10 @@
next if pa[0].nil?
self.class.qp.normalize_params(params, Plezi.try_utf8!(Rack::Utils.unescape(key)),
Plezi.try_utf8!(Rack::Utils.unescape(pa.shift)), 100)
end
params['*'.freeze] = pa unless pa.empty?
- true
+ params
end
def match(req_path, request = nil)
# puts "#{req_path} starts with #{@prefix}? #{req_path.start_with?(@prefix)}"
req_path.start_with?(@prefix) && fits_params(req_path, request)