module Roda::RodaPlugins::StaticPathInfo::RequestMethods

def initialize(*)

Set remaining_path when initializing.
def initialize(*)
  super
  @remaining_path = @env[PATH_INFO]
end

def keep_remaining_path

the method returns.
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

The already matched part of the path, including the original SCRIPT_NAME.
def matched_path
  e = @env
  e[SCRIPT_NAME] + e[PATH_INFO].chomp(@remaining_path)
end

def run(_)

a URL mapper.
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)

Update remaining_path with the remaining characters
def update_remaining_path(remaining)
  @remaining_path = remaining
end