module Roda::RodaPlugins::PathRewriter::RequestMethods
Public Class Methods
Source
# File lib/roda/plugins/path_rewriter.rb, line 85 def initialize(scope, env) path_info = env['PATH_INFO'] rewrite_path(scope.class.opts[:path_info_rewrites], path_info) super remaining_path = @remaining_path = @remaining_path.dup rewrite_path(scope.class.opts[:remaining_path_rewrites], remaining_path) end
Rewrite remaining_path and/or PATH_INFO based on the path rewrites.
Calls superclass method
Private Instance Methods
Source
# File lib/roda/plugins/path_rewriter.rb, line 97 def rewrite_path(replacements, path) replacements.each do |was, is| if is.is_a?(Proc) path.sub!(was){is.call($~)} else path.sub!(was, is) end end end
Rewrite the given path using the given replacements.