lib/lamby/rack.rb in lamby-2.8.0 vs lib/lamby/rack.rb in lamby-3.0.0
- old
+ new
@@ -5,9 +5,25 @@
LAMBDA_EVENT = 'lambda.event'.freeze
LAMBDA_CONTEXT = 'lambda.context'.freeze
HTTP_X_REQUESTID = 'HTTP_X_REQUEST_ID'.freeze
HTTP_COOKIE = 'HTTP_COOKIE'.freeze
+
+ class << self
+
+ def lookup(type, event)
+ types[type] || types.values.detect { |t| t.handle?(event) }
+ end
+
+ # Order is important. REST is hardest to isolated with handle? method.
+ def types
+ { alb: RackAlb,
+ http: RackHttp,
+ rest: RackRest,
+ api: RackRest }
+ end
+
+ end
attr_reader :event, :context
def initialize(event, context)
@event = event