Sha256: f6d42185bfb46dea29e520b7c1b227e0bde90987d1c8790c675ddac2d2781202

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

module Lamby
  class RackRest < Lamby::Rack

    def response(handler)
      if handler.base64_encodeable?
        { isBase64Encoded: true, body: handler.body64 }
      else
        super
      end
    end

    private

    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

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lamby-2.5.3 lib/lamby/rack_rest.rb
lamby-2.5.2 lib/lamby/rack_rest.rb
lamby-2.5.1 lib/lamby/rack_rest.rb
lamby-2.5.0 lib/lamby/rack_rest.rb
lamby-2.2.2 lib/lamby/rack_rest.rb
lamby-2.2.1 lib/lamby/rack_rest.rb
lamby-2.2.0 lib/lamby/rack_rest.rb
lamby-2.1.0 lib/lamby/rack_rest.rb
lamby-2.0.1 lib/lamby/rack_rest.rb
lamby-2.0.0 lib/lamby/rack_rest.rb