Class: Rack::Mount::PathPrefix
- Inherits:
-
Object
- Object
- Rack::Mount::PathPrefix
- Defined in:
- lib/rack/mount/path_prefix.rb
Overview
:nodoc:
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, path_prefix = nil) ⇒ PathPrefix
constructor
A new instance of PathPrefix.
Constructor Details
#initialize(app, path_prefix = nil) ⇒ PathPrefix
Returns a new instance of PathPrefix.
4 5 6 |
# File 'lib/rack/mount/path_prefix.rb', line 4 def initialize(app, path_prefix = nil) @app, @path_prefix = app, /^#{Regexp.escape(path_prefix)}/.freeze end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rack/mount/path_prefix.rb', line 8 def call(env) path_info = Const::PATH_INFO if env[path_info] =~ @path_prefix env[path_info].sub!(@path_prefix, Const::EMPTY_STRING) env[path_info] = Const::SLASH if env[path_info].empty? end @app.call(env) end |