Sha256: 24639b6e363aa72f19a11c9cba11306ecbaf15f5f1dc892b0535c9ebda567929

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

require 'middleware/metrics_middleware'
require 'middleware/request_id_middleware'
require 'middleware/json_parse_errors'

module ZuoraConnect
  class Railtie < Rails::Railtie
    config.before_initialize do
      version = Rails.version
      if version >= "5.0.0"
        ::Rails.configuration.public_file_server.enabled = true
      elsif version >= "4.2.0"
        ::Rails.configuration.serve_static_files = true
      else
        ::Rails.configuration.serve_static_assets = true
      end
      ::Rails.configuration.action_dispatch.x_sendfile_header = nil
    end

    initializer "zuora_connect.configure_rails_initialization" do |app|
      app.middleware.insert_after Rack::Sendfile, ZuoraConnect::MetricsMiddleware
      app.middleware.insert_after ActionDispatch::RequestId, ZuoraConnect::RequestIdMiddleware
      app.config.middleware.use ZuoraConnect::JsonParseErrors
    end

    if defined? Prometheus
      require 'rack'
      require 'prometheus/middleware/exporter'
      initializer "prometheus.configure_rails_initialization" do |app|
        app.middleware.insert_after ZuoraConnect::MetricsMiddleware, Prometheus::Middleware::Exporter, path: '/connect/internal/metrics'
        app.config.middleware.use Rack::Deflater, if: ->(env, *) { env['PATH_INFO'] == '/connect/internal/metrics' }
      end
    end

    # hook to process_action
    ActiveSupport::Notifications.subscribe('process_action.action_controller', ZuoraConnect::PageRequest.new)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zuora_connect-3.0.2.pre.d lib/zuora_connect/railtie.rb
zuora_connect-3.0.2.pre.c lib/zuora_connect/railtie.rb
zuora_connect-3.0.2.pre.b lib/zuora_connect/railtie.rb
zuora_connect-3.0.2.pre.a lib/zuora_connect/railtie.rb
zuora_connect-3.0.1 lib/zuora_connect/railtie.rb