Class: Rack::App::Middlewares::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/app/middlewares/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, config) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
9
10
11
# File 'lib/rack/app/middlewares/configuration.rb', line 6

def initialize(app, config)
  @app = app || raise
  @serializer = config.serializer || raise
  @handler_class = config.app_class || raise
  @payload_parser = config.payload_builder.to_parser || raise
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/rack/app/middlewares/configuration.rb', line 13

def call(env)
  env[::Rack::App::Constants::ENV::HANDLER]= handler(env)
  env[::Rack::App::Constants::ENV::SERIALIZER]= @serializer
  env[::Rack::App::Constants::ENV::PAYLOAD_PARSER]= @payload_parser
  env[::Rack::App::Constants::ENV::PAYLOAD_GETTER]= lambda do
    env[::Rack::App::Constants::ENV::PARSED_PAYLOAD] ||= env[::Rack::App::Constants::ENV::PAYLOAD_PARSER].parse_env(env)
  end
  @app.call(env)
end