module Roda::RodaPlugins::StaticPathInfo::RequestMethods
def initialize(*)
def initialize(*) super @remaining_path = @env[PATH_INFO] end
def keep_remaining_path
Yield to the block, restoring the remaining_path before
def keep_remaining_path path = @remaining_path yield ensure @remaining_path = path end
def matched_path
def matched_path e = @env e[SCRIPT_NAME] + e[PATH_INFO].chomp(@remaining_path) end
def run(_)
before dispatching to another rack app, so the app still works as
Update SCRIPT_NAME/PATH_INFO based on the current remaining_path
def run(_) e = @env path = @remaining_path begin script_name = e[SCRIPT_NAME] path_info = e[PATH_INFO] e[SCRIPT_NAME] += path_info.chomp(path) e[PATH_INFO] = path super ensure e[SCRIPT_NAME] = script_name e[PATH_INFO] = path_info end end
def update_remaining_path(remaining)
def update_remaining_path(remaining) @remaining_path = remaining end