Sha256: c3ce05ee86d1b7e2b9309d815e2c0ee521a7df88e35c9529bc98cc82ae02be55

Contents?: true

Size: 969 Bytes

Versions: 1

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

module Hanami
  # @api private
  module Providers
    # Provider source to register Rack integration components in Hanami slices.
    #
    # @see Hanami::Providers::Logger
    # @see Hanami::Web::RackLogger
    # @see https://github.com/rack/rack
    # @see https://dry-rb.org/gems/dry-monitor/
    #
    # @api private
    # @since 2.0.0
    class Rack < Dry::System::Provider::Source
      # @api private
      def prepare
        require "dry/monitor"
        require "hanami/web/rack_logger"

        Dry::Monitor.load_extensions(:rack)
      end

      # @api private
      def start
        target.start :logger

        notifications = target[:notifications]

        monitor_middleware = Dry::Monitor::Rack::Middleware.new(notifications)

        rack_logger = Hanami::Web::RackLogger.new(target[:logger])
        rack_logger.attach(monitor_middleware)

        register "monitor", monitor_middleware
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-2.0.0.rc1 lib/hanami/providers/rack.rb