Sha256: da273d918165787a5887af57e6340560336abec432c1d80777a024bee61e5a50

Contents?: true

Size: 612 Bytes

Versions: 44

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true
class Rack::App::Router::Tree::Leaf::Mounted::Application < Rack::App::Router::Tree::Leaf::Mounted
  protected

  def initialize(endpoint)
    @app = build(endpoint)
  end

  def build(endpoint)
    builder = Rack::Builder.new
    builder.use(Rack::App::Middlewares::PathInfoCutter, mount_path(endpoint))
    builder.run(endpoint.to_app)
    builder.to_app
  end

  def mount_path(endpoint)
    mount_path_parts = (endpoint.request_path.split('/') - [Rack::App::Constants::PATH::APPLICATION, ''])
    mount_path_parts.empty? ? '' : Rack::App::Utils.join(mount_path_parts)
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
rack-app-6.1.0 lib/rack/app/router/tree/leaf/mounted/application.rb
rack-app-6.0.0 lib/rack/app/router/tree/leaf/mounted/application.rb
rack-app-5.12.0 lib/rack/app/router/tree/leaf/mounted/application.rb
rack-app-5.11.1 lib/rack/app/router/tree/leaf/mounted/application.rb