class Lamby::RackRest
Public Class Methods
handle?(event)
click to toggle source
# File lib/lamby/rack_rest.rb, line 6 def handle?(event) event.key?('httpMethod') end
Public Instance Methods
response(handler)
click to toggle source
Calls superclass method
Lamby::Rack#response
# File lib/lamby/rack_rest.rb, line 12 def response(handler) if handler.base64_encodeable? { isBase64Encoded: true, body: handler.body64 } else super end.tap do |r| if cookies = handler.set_cookies r[:multiValueHeaders] ||= {} r[:multiValueHeaders]['Set-Cookie'] = cookies end end end
Private Instance Methods
env_base()
click to toggle source
# File lib/lamby/rack_rest.rb, line 27 def env_base { ::Rack::REQUEST_METHOD => event['httpMethod'], ::Rack::SCRIPT_NAME => '', ::Rack::PATH_INFO => event['path'] || '', ::Rack::QUERY_STRING => query_string, ::Rack::SERVER_NAME => headers['Host'], ::Rack::SERVER_PORT => headers['X-Forwarded-Port'], ::Rack::SERVER_PROTOCOL => event.dig('requestContext', 'protocol') || 'HTTP/1.1', ::Rack::RACK_VERSION => ::Rack::VERSION, ::Rack::RACK_URL_SCHEME => 'https', ::Rack::RACK_INPUT => StringIO.new(body || ''), ::Rack::RACK_ERRORS => $stderr, ::Rack::RACK_MULTITHREAD => false, ::Rack::RACK_MULTIPROCESS => false, ::Rack::RACK_RUNONCE => false, LAMBDA_EVENT => event, LAMBDA_CONTEXT => context }.tap do |env| ct = content_type cl = content_length env['CONTENT_TYPE'] = ct if ct env['CONTENT_LENGTH'] = cl if cl end end