Sha256: fefe179c8ff28cec8b55f151953ee13f9ed98a0992297839b8afe412389c83d7

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require "dry/system/plugins"
require_relative "endpoint_resolver"
require_relative "rack_logger"

module Snowpack
  module Web
    module Plugin
      def self.extended(system)
        super

        system.setting :web do
          setting :routing do
            setting :endpoint_resolver, EndpointResolver
            setting :action_key_namespace, "web.actions"
          end

          setting :logging do
            setting :filter_params, %w[_csrf password password_confirmation]
          end
        end

        system.after :configure do
          register_rack_monitor
          attach_rack_logger
        end
      end

      def register_rack_monitor
        return self if key?(:rack_monitor)
        register :rack_monitor, Dry::Monitor::Rack::Middleware.new(self[:notifications])
        self
      end

      def attach_rack_logger
        RackLogger.new(self[:logger], filter_params: config.web.logging.filter_params).attach(self[:rack_monitor])
        self
      end
    end

    Dry::System::Plugins.register :web, Plugin
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snowpack-1.0.0.alpha7 lib/snowpack/web/plugin.rb
snowpack-1.0.0.alpha6 lib/snowpack/web/plugin.rb
snowpack-1.0.0.alpha5 lib/snowpack/web/plugin.rb
snowpack-1.0.0.alpha4 lib/snowpack/web/plugin.rb
snowpack-1.0.0.alpha3 lib/snowpack/web/plugin.rb
snowpack-1.0.0.alpha2 lib/snowpack/web/plugin.rb