Class: Hanami::Router::MountedPath
- Defined in:
- gems/gems/hanami-router-2.1.0/lib/hanami/router/mounted_path.rb
Overview
Instance Method Summary collapse
- #endpoint_and_params(env) ⇒ Object
-
#initialize(prefix, app) ⇒ MountedPath
constructor
A new instance of MountedPath.
Constructor Details
#initialize(prefix, app) ⇒ MountedPath
Returns a new instance of MountedPath
Source: | on GitHub
def initialize(prefix, app) @prefix = prefix @app = app end |
Instance Method Details
#endpoint_and_params(env) ⇒ Object
Source: | on GitHub
def endpoint_and_params(env) return [] unless (match = @prefix.peek_match(env[::Rack::PATH_INFO])) if @prefix.to_s == "/" env[::Rack::SCRIPT_NAME] = EMPTY_STRING else env[::Rack::SCRIPT_NAME] = env[::Rack::SCRIPT_NAME].to_s + @prefix.to_s env[::Rack::PATH_INFO] = env[::Rack::PATH_INFO].sub(@prefix.to_s, EMPTY_STRING) env[::Rack::PATH_INFO] = DEFAULT_PREFIX if env[::Rack::PATH_INFO] == EMPTY_STRING end [@app, match.named_captures] end |