Sha256: 73f7f9b7568f86791c17b90d16c3211175f877b1556dc505c4318463b186d694

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 KB

Contents

require "rails-pg-extras"
require "rails_pg_extras/version"

module RailsPgExtras::Web
  class ApplicationController < ActionController::Base
    before_action :validate_credentials!
    layout "rails_pg_extras/web/application"

    REQUIRED_EXTENSIONS = {
      pg_stat_statements: %i[calls outliers pg_stat_statements_reset],
      pg_buffercache: %i[buffercache_stats buffercache_usage],
      sslinfo: %i[ssl_used]
    }

    ACTIONS = %i[kill_all pg_stat_statements_reset add_extensions]

    if ENV['RAILS_PG_EXTRAS_USER'].present? && ENV['RAILS_PG_EXTRAS_PASSWORD'].present?
      http_basic_authenticate_with name: ENV.fetch('RAILS_PG_EXTRAS_USER'), password: ENV.fetch('RAILS_PG_EXTRAS_PASSWORD')
    end

    def validate_credentials!
      if (ENV['RAILS_PG_EXTRAS_USER'].blank? || ENV['RAILS_PG_EXTRAS_PASSWORD'].blank?) && !RailsPgExtras.configuration.public_dashboard
        raise "Missing credentials for rails-pg-extras dashboard! If you want to enable public dashboard please set RAILS_PG_EXTRAS_PUBLIC_DASHBOARD=true"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rails-pg-extras-5.3.1 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.3.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.2.5 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.2.4 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.2.3 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.2.2 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.2.1 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.2.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.1.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-5.0.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-4.13.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-4.12.2 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-4.12.1 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-4.12.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-4.10.0 app/controllers/rails_pg_extras/web/application_controller.rb
rails-pg-extras-4.9.0 app/controllers/rails_pg_extras/web/application_controller.rb