Sha256: 8b63a2d495278d83e332199b113dbdbb8b0cef0a85c7cf0e9b235f30c4c24ff8

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'pact_broker/ui/controllers/index'
require 'pact_broker/ui/controllers/groups'
require 'pact_broker/ui/controllers/matrix'
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 "/" do
            run PactBroker::UI::Controllers::Index
          end
        }
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-2.16.0 lib/pact_broker/ui/app.rb
pact_broker-2.15.0 lib/pact_broker/ui/app.rb
pact_broker-2.14.0 lib/pact_broker/ui/app.rb
pact_broker-2.13.1 lib/pact_broker/ui/app.rb
pact_broker-2.13.0 lib/pact_broker/ui/app.rb