Class: Lamby::Rack

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(event, context) ⇒ Rack

Returns a new instance of Rack.



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

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



25
26
27
# File 'lib/lamby/rack.rb', line 25

def context
  @context
end

#eventObject (readonly)

Returns the value of attribute event.



25
26
27
# File 'lib/lamby/rack.rb', line 25

def event
  @event
end

Class Method Details

.lookup(type, event) ⇒ Object



11
12
13
# File 'lib/lamby/rack.rb', line 11

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.



16
17
18
19
20
21
# File 'lib/lamby/rack.rb', line 16

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

Instance Method Details

#envObject



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

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

#multi_value?Boolean

Returns:

  • (Boolean)


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

def multi_value?
  false
end

#response(_handler) ⇒ Object



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

def response(_handler)
  {}
end