Module: PhobosCheckpointUI::App

Defined in:
lib/phobos_checkpoint_ui/app.rb

Class Method Summary collapse

Class Method Details

.new(api_app:, config: {}, saml_handler: PhobosCheckpointUI::SamlHandler, logger_middleware: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/phobos_checkpoint_ui/app.rb', line 3

def self.new(api_app:,
             config: {},
             saml_handler: PhobosCheckpointUI::SamlHandler,
             logger_middleware: nil
            )

  StaticApp.configs = config

  if logger_middleware.present?
    middleware_klass = logger_middleware.dig(:class)
    raise ':class key missing in :logger_middleware parameter' unless middleware_klass

    StaticApp.use(middleware_klass, logger_middleware.dig(:opts) || {})
  else
    StaticApp.use(Rack::NullLogger)
  end

  Rack::URLMap.new(
    '/' => StaticApp.new(api_app, saml_handler),
    '/ping' => Proc.new { |env| ['200', { 'Content-Type' => 'text/plain' }, ['PONG']] }
  )
end