Class: Jets::Controller::Rack::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/controller/rack/env.rb

Instance Method Summary collapse

Constructor Details

#initialize(event, context, options = {}) ⇒ Env

Returns a new instance of Env.



8
9
10
# File 'lib/jets/controller/rack/env.rb', line 8

def initialize(event, context, options={})
  @event, @context, @options = event, context, options
end

Instance Method Details

#convertObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jets/controller/rack/env.rb', line 12

def convert
  options = {}
  options = add_top_level(options)
  options = add_http_headers(options)
  path = path_with_base_path || @event['path'] || '/' # always set by API Gateway but might not be when testing shim, so setting it to make testing easier

  env = Rack::MockRequest.env_for(path, options)
  if @options[:adapter]
    env['adapter.event'] = @event
    env['adapter.context'] = @context
  end
  env
end