class Graphql::Dashboard::Limiters::LimitersController
Constants
- FALLBACK_CSP_NONCE_GENERATOR
- INSTALLABLE_COMPONENT_HEADER_HTML
- INSTALLABLE_COMPONENT_MESSAGE_HTML
Public Instance Methods
Source
# File lib/graphql/dashboard/limiters.rb, line 11 def show name = params[:name] @title = case name when "runtime" "Runtime Limiter" when "active_operations" "Active Operation Limiter" when "mutations" "Mutation Limiter" else raise ArgumentError, "Unknown limiter name: #{name}" end limiter = limiter_for(name) if limiter.nil? @install_path = "http://graphql-ruby.org/limiters/#{name}" else @chart_mode = params[:chart] || "day" @current_soft = limiter.soft_limit_enabled? @histogram = limiter.dashboard_histogram(@chart_mode) # These configs may have already been defined by the application; provide overrides here if not. request.content_security_policy_nonce_generator ||= FALLBACK_CSP_NONCE_GENERATOR nonce_dirs = request.content_security_policy_nonce_directives || [] if !nonce_dirs.include?("style-src") nonce_dirs += ["style-src"] request.content_security_policy_nonce_directives = nonce_dirs end @csp_nonce = request.content_security_policy_nonce end end
Source
# File lib/graphql/dashboard/limiters.rb, line 43 def update name = params[:name] limiter = limiter_for(name) if limiter limiter.toggle_soft_limit flash[:success] = if limiter.soft_limit_enabled? "Enabled soft limiting -- over-limit traffic will be logged but not rejected." else "Disabled soft limiting -- over-limit traffic will be rejected." end else flash[:warning] = "No limiter configured for #{name.inspect}" end redirect_to graphql_dashboard.limiters_limiter_path(name, chart: params[:chart]) end