Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
elixir-aws-handler / lib / elixir / aws / handler / lambda.rb
Size: Mime:
require 'elixir/aws/handler/version'

module Elixir
  module Aws
    module Handler
      class Lambda
        class << self
          def call(app, event, context, use_stage)
            new(app, event, context, use_stage).call.response
          end

        end

        def initialize(app, event, context, use_stage)
          @app = app
          @event = event
          @context = context
          @rack = Rack.new event, context, use_stage
          @called = false
        end

        def response
          { statusCode: status,
            headers: headers,
            body: body }
        end

        def status
          @status
        end

        def headers
          @headers
        end

        def body
          @rbody ||= ''.tap do |rbody| # rubocop:disable all
            @body.each { |part| rbody << part }
          end
        end

        def call
          return self if @called

          @status, @headers, @body = call_app
          @called = true
          self
        end

        private

        def call_app
          # if Debug.on?(@event)
          #   Debug.call @event, @context, @rack.env
          # else
          @app.call @rack.env
          # end
        end
      end
      # Your code goes here...
    end
  end
end