Class: Lamby::RackAlb
- Inherits:
-
Rack
- Object
- Rack
- Lamby::RackAlb
show all
- Defined in:
- lib/lamby/rack_alb.rb
Constant Summary
Constants inherited
from Rack
Lamby::Rack::HTTP_COOKIE, Lamby::Rack::HTTP_X_REQUESTID, Lamby::Rack::HTTP_X_REQUEST_START, Lamby::Rack::LAMBDA_CONTEXT, Lamby::Rack::LAMBDA_EVENT
Instance Attribute Summary
Attributes inherited from Rack
#context, #event
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Rack
#env, #initialize, lookup, types
Constructor Details
This class inherits a constructor from Lamby::Rack
Class Method Details
.handle?(event) ⇒ Boolean
6
7
8
9
|
# File 'lib/lamby/rack_alb.rb', line 6
def handle?(event)
event.key?('httpMethod') &&
event.dig('requestContext', 'elb')
end
|
Instance Method Details
#alb? ⇒ Boolean
13
14
15
|
# File 'lib/lamby/rack_alb.rb', line 13
def alb?
true
end
|
#multi_value? ⇒ Boolean
17
18
19
|
# File 'lib/lamby/rack_alb.rb', line 17
def multi_value?
event.key? 'multiValueHeaders'
end
|
#response(handler) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/lamby/rack_alb.rb', line 21
def response(handler)
hhdrs = handler.
if multi_value?
= hhdrs.transform_values { |v| Array[v].compact.flatten }
['Set-Cookie'] = handler.set_cookies if handler.set_cookies
end
status_description = "#{handler.status} #{::Rack::Utils::HTTP_STATUS_CODES[handler.status]}"
base64_encode = handler.base64_encodeable?(hhdrs)
body = Base64.strict_encode64(handler.body) if base64_encode
{ multiValueHeaders: ,
statusDescription: status_description,
isBase64Encoded: base64_encode,
body: body }.compact
end
|