lib/lamby/handler.rb in lamby-0.5.1 vs lib/lamby/handler.rb in lamby-0.6.0
- old
+ new
@@ -1,21 +1,21 @@
module Lamby
class Handler
class << self
- def call(app, event, context)
- new(app, event, context).call.response
+ def call(app, event, context, options = {})
+ new(app, event, context, options).call.response
end
end
- def initialize(app, event, context)
+ def initialize(app, event, context, options = {})
@app = app
@event = event
@context = context
- @rack = Lamby::Rack.new event, context
+ @options = options
@called = false
end
def response
{ statusCode: status,
@@ -44,14 +44,23 @@
self
end
private
+ def rack
+ @rack ||= case @options[:rack]
+ when :api
+ Lamby::RackApi.new @event, @context
+ else
+ Lamby::RackAlb.new @event, @context
+ end
+ end
+
def call_app
if Debug.on?(@event)
- Debug.call @event, @context, @rack.env
+ Debug.call @event, @context, rack.env
else
- @app.call @rack.env
+ @app.call rack.env
end
end
end
end