Class: RackHttpScriptName
- Inherits:
-
Object
- Object
- RackHttpScriptName
- Defined in:
- lib/rack_http_script_name.rb,
lib/rack_http_script_name/version.rb
Constant Summary collapse
- SCRIPT_NAME =
'SCRIPT_NAME'.freeze
- HTTP_SCRIPT_NAME =
'HTTP_SCRIPT_NAME'.freeze
- VERSION =
"0.0.2"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RackHttpScriptName
constructor
A new instance of RackHttpScriptName.
Constructor Details
#initialize(app) ⇒ RackHttpScriptName
Returns a new instance of RackHttpScriptName.
4 5 6 |
# File 'lib/rack_http_script_name.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rack_http_script_name.rb', line 10 def call(env) script_name = env['SCRIPT_NAME'] http_script_name = env['HTTP_SCRIPT_NAME'] if script_name.empty? && http_script_name && !http_script_name.empty? path_info = env['PATH_INFO'] env["SCRIPT_NAME"] = http_script_name env["PATH_INFO"] = env["PATH_INFO"][http_script_name.length..-1] end @app.call(env) end |