Sha256: 0066999db378cdf15126c32e1ef6253aab83d97651ced199e6443be20bd43fc9

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

require 'pact_broker/ui/controllers/index'
require 'pact_broker/ui/controllers/groups'
require 'pact_broker/ui/controllers/matrix'
require 'pact_broker/ui/controllers/error_test'
require 'pact_broker/doc/controllers/app'

module PactBroker
  module UI
    class PathInfoFixer
      PATH_INFO = 'PATH_INFO'.freeze

      def initialize app
        @app = app
      end

      def call env
        env[PATH_INFO] = '/' if env[PATH_INFO] == ''
        @app.call(env)
      end
    end

    class App

      def initialize
        @app = ::Rack::Builder.new {

          map "/ui/relationships" do
            run PactBroker::UI::Controllers::Index
          end

          map "/groups" do
            run PactBroker::UI::Controllers::Groups
          end

          map "/doc" do
            run PactBroker::Doc::Controllers::App
          end

          map "/matrix" do
            use PathInfoFixer
            run PactBroker::UI::Controllers::Matrix
          end

          map "/test/error" do
            use PathInfoFixer
            run PactBroker::UI::Controllers::ErrorTest
          end

          map "/" do
            use PathInfoFixer
            run PactBroker::UI::Controllers::Index
          end
        }
      end

      def call env
        @app.call(env)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pact_broker-2.63.0 lib/pact_broker/ui/app.rb
pact_broker-2.62.0 lib/pact_broker/ui/app.rb
pact_broker-2.61.0 lib/pact_broker/ui/app.rb
pact_broker-2.60.1 lib/pact_broker/ui/app.rb
pact_broker-2.60.0 lib/pact_broker/ui/app.rb
pact_broker-2.59.2 lib/pact_broker/ui/app.rb
pact_broker-2.59.1 lib/pact_broker/ui/app.rb
pact_broker-2.59.0 lib/pact_broker/ui/app.rb
pact_broker-2.58.3 lib/pact_broker/ui/app.rb
pact_broker-2.58.2 lib/pact_broker/ui/app.rb
pact_broker-2.58.0 lib/pact_broker/ui/app.rb
pact_broker-2.57.0 lib/pact_broker/ui/app.rb
pact_broker-2.56.1 lib/pact_broker/ui/app.rb
pact_broker-2.56.0 lib/pact_broker/ui/app.rb
pact_broker-2.55.0 lib/pact_broker/ui/app.rb