Sha256: 0c7d799bfc8f92bb4949756883e8870097c08378b65fb62f995726df27e25ef0

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module Modern
  class App
    module RequestHandling
      # Encapsulates all non-derived portions of the request to run security
      # actions inside of it.
      class PartialRequestContainer
        attr_reader :logger
        attr_reader :configuration
        attr_reader :services
        attr_reader :route

        attr_reader :request
        attr_reader :response

        def initialize(logger, configuration, services, route, request, response)
          @logger = logger
          @configuration = configuration
          @services = services
          @route = route

          @request = request
          @response = response
        end

        def with_logger_fields(fields = {})
          original_logger = @logger
          @logger = original_logger.child(fields)

          ret = yield

          @logger = original_logger

          ret
        end
      end

      # Encapsulates all portions of the request, including params and body,
      # to have a route action run inside of it. This will be subclassed by
      # {Modern::Descriptor::Route}s that incorporate helper libraries.
      class FullRequestContainer < PartialRequestContainer
        attr_reader :params
        attr_reader :body

        def initialize(logger, configuration, services, route, request, response, params, body)
          super(logger, configuration, services, route, request, response)

          @params = params
          @body = body
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
modern-0.5.0 lib/modern/app/request_handling/request_container.rb
modern-0.4.6 lib/modern/app/request_handling/request_container.rb
modern-0.4.5 lib/modern/app/request_handling/request_container.rb
modern-0.4.4 lib/modern/app/request_handling/request_container.rb
modern-0.4.3 lib/modern/app/request_handling/request_container.rb
modern-0.4.2 lib/modern/app/request_handling/request_container.rb