Sha256: e6d910dc97d8c88f11aa1206b6f6ec7b75f4bba7209e50df861fe3ce63c63d02

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

cs__scoped_require 'contrast/utils/operating_environment'

module Contrast
  module Agent
    # A Railtie to allow for the automatic hooking of the Agent into a Rails
    # application.
    class Railtie < Rails::Railtie
      initializer 'Contrast Ruby Agent Initializer' do |app|
        if defined?(Rails) && defined?(Rails.logger)
          Rails.logger.debug('In railtie ::')
          Rails.logger.debug(app.middleware.inspect)
        end

        if Contrast::Utils::OperatingEnvironment.unsupported?
          Rails.logger.debug('Detected a non-webserver context, skipping Contrast middleware insertion.')
        else
          # Keep our middleware at the outermost layer of the onion
          app.middleware.insert_before 0, Contrast::Agent::Middleware
        end
      end

      rake_tasks do
        load 'contrast/tasks/service.rb'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-3.8.5 lib/contrast/agent/railtie.rb
contrast-agent-3.8.4 lib/contrast/agent/railtie.rb