class Rage::Router::DSL::Handler

def __on(method, path, to, constraints, defaults)

def __on(method, path, to, constraints, defaults)
  # handle calls without controller inside resources:
  #   resources :comments do
  #     post :like
  #   end
  if !to
    if @controllers.any?
      to = "#{@controllers.last}##{path}"
    else
      raise ArgumentError, "Missing :to key on routes definition, please check your routes."
    end
  end
  # process path to ensure it starts with "/" and doesn't end with "/"
  if path != "/"
    path = "/#{path}" unless path.start_with?("/")
    path = path.delete_suffix("/") if path.end_with?("/")
  end
  # correctly process root helpers inside `scope` calls
  if path == "/" && @path_prefixes.any?
    path = ""
  end
  path_prefix = @path_prefixes.any? ? "/#{@path_prefixes.join("/")}" : nil
  module_prefix = @module_prefixes.any? ? "#{@module_prefixes.join("/")}/" : nil
  defaults = (defaults ? @defaults + [defaults] : @defaults).reduce(&:merge)
  if to.is_a?(String)
    @router.on(method, "#{path_prefix}#{path}", "#{module_prefix}#{to}", constraints: constraints || {}, defaults: defaults)
  else
    @router.on(method, "#{path_prefix}#{path}", to, constraints: constraints || {}, defaults: defaults)
  end
end