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::LAMBDA_CONTEXT, Lamby::Rack::LAMBDA_EVENT
Instance Attribute Summary
Attributes inherited from Rack
#context, #event
Instance Method Summary
collapse
Methods inherited from Rack
#env, #initialize
Methods included from SamHelpers
#sam_local?
Constructor Details
This class inherits a constructor from Lamby::Rack
Instance Method Details
#alb? ⇒ Boolean
4
5
6
|
# File 'lib/lamby/rack_alb.rb', line 4
def alb?
true
end
|
#multi_value? ⇒ Boolean
8
9
10
|
# File 'lib/lamby/rack_alb.rb', line 8
def multi_value?
event.key? 'multiValueHeaders'
end
|
#response(handler) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/lamby/rack_alb.rb', line 12
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
|