Sha256: c34df925697ef152a50a1dd3a316c363f7eac7094be065a9eeb641ce4e110aea

Contents?: true

Size: 768 Bytes

Versions: 47

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

module ZuoraConnect
  module Middleware
    # Enables requests to be served from dynamic paths, determined by headers
    class Hallway
      UI_PATH = 'HTTP_ZUORA_UI_PATH'
      LAYOUT_ID = 'HTTP_ZUORA_LAYOUT_FETCH_TEMPLATE_ID'

      def initialize(app)
        @app = app
      end

      def call(env)
        dynamic_path = env[UI_PATH].presence || layout_id(env)

        Thread.current[:isHallway] = dynamic_path

        if dynamic_path.present?
          env['SCRIPT_NAME'] = dynamic_path
          env['PATH_INFO'] = env['PATH_INFO'].sub(dynamic_path, '')
        end

        @app.call(env)
      end

      private

      def layout_id(env)
        "/#{env[LAYOUT_ID]}" if env[LAYOUT_ID].present?
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
zuora_connect-3.2.10 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.9 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.8 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.7 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.6 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.5 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.4 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.3 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.2 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.2.0 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.g lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.f lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.e lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.d lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.c lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.b lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5.pre.a lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.5 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.4 lib/zuora_connect/middleware/hallway.rb
zuora_connect-3.1.3 lib/zuora_connect/middleware/hallway.rb