Class: Lamby::Rack

Inherits:
Object
  • Object
show all
Includes:
SamHelpers
Defined in:
lib/lamby/rack.rb

Direct Known Subclasses

RackAlb, RackHttp, RackRest

Constant Summary collapse

LAMBDA_EVENT =
'lambda.event'.freeze
LAMBDA_CONTEXT =
'lambda.context'.freeze
HTTP_X_REQUESTID =
'HTTP_X_REQUEST_ID'.freeze
HTTP_X_REQUEST_START =
'HTTP_X_REQUEST_START'.freeze
'HTTP_COOKIE'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SamHelpers

#sam_local?

Constructor Details

#initialize(event, context) ⇒ Rack

Returns a new instance of Rack.



30
31
32
33
# File 'lib/lamby/rack.rb', line 30

def initialize(event, context)
  @event = event
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



28
29
30
# File 'lib/lamby/rack.rb', line 28

def context
  @context
end

#eventObject (readonly)

Returns the value of attribute event.



28
29
30
# File 'lib/lamby/rack.rb', line 28

def event
  @event
end

Class Method Details

.lookup(type, event) ⇒ Object



14
15
16
# File 'lib/lamby/rack.rb', line 14

def lookup(type, event)
  types[type] || types.values.detect { |t| t.handle?(event) }
end

.typesObject

Order is important. REST is hardest to isolated with handle? method.



19
20
21
22
23
24
# File 'lib/lamby/rack.rb', line 19

def types
  { alb:  RackAlb,
    http: RackHttp,
    rest: RackRest,
    api:  RackRest }
end

Instance Method Details

#envObject



35
36
37
# File 'lib/lamby/rack.rb', line 35

def env
  @env ||= env_base.merge!(env_headers)
end

#multi_value?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/lamby/rack.rb', line 43

def multi_value?
  false
end

#response(_handler) ⇒ Object



39
40
41
# File 'lib/lamby/rack.rb', line 39

def response(_handler)
  {}
end