Sha256: dfa0f45e7186f3d3c249babc1a0c5358dedef0f9957d29d5eb37e3b9df52913a

Contents?: true

Size: 1.59 KB

Versions: 17

Compression:

Stored size: 1.59 KB

Contents

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

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.middleware.insert_before Rack::Runtime, ZuoraConnect::BadMultipartFormDataSanitizer
      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

17 entries across 17 versions & 1 rubygems

Version Path
zuora_connect-3.0.1.pre.d lib/zuora_connect/railtie.rb
zuora_connect-3.0.1.pre.c lib/zuora_connect/railtie.rb
zuora_connect-3.0.1.pre.b lib/zuora_connect/railtie.rb
zuora_connect-3.0.1.pre.a lib/zuora_connect/railtie.rb
zuora_connect-3.0.0 lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.y lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.x lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.w lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.v lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.u lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.t lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.s lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.r lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.q lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.p lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.o lib/zuora_connect/railtie.rb
zuora_connect-3.0.0.pre.n lib/zuora_connect/railtie.rb