Class: Rack::App::Middlewares::Payload::ParserSetter

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

Constant Summary collapse

PARSER =
::Rack::App::Constants::ENV::PAYLOAD_PARSER
PARSED =
::Rack::App::Constants::ENV::PARSED_PAYLOAD
GETTER =
::Rack::App::Constants::ENV::PAYLOAD_GETTER

Instance Method Summary collapse

Constructor Details

#initialize(app, payload_builder) ⇒ ParserSetter

Returns a new instance of ParserSetter.



7
8
9
10
# File 'lib/rack/app/middlewares/payload/parser_setter.rb', line 7

def initialize(app, payload_builder)
  @payload_parser = payload_builder.parser.to_parser
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
# File 'lib/rack/app/middlewares/payload/parser_setter.rb', line 12

def call(env)
  env[PARSER]= @payload_parser
  env[GETTER]= lambda { env[PARSED] ||= env[PARSER].parse_env(env) }
  @app.call(env)
end