Module: ThreeScale::Backend::Rack
- Defined in:
- lib/3scale/backend/rack.rb,
lib/3scale/backend/rack/prometheus.rb,
lib/3scale/backend/rack/exception_catcher.rb,
lib/3scale/backend/rack/internal_error_catcher.rb
Defined Under Namespace
Classes: ExceptionCatcher, InternalErrorCatcher, Prometheus
Class Method Summary collapse
Class Method Details
.run(rack) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/3scale/backend/rack.rb', line 14 def self.run(rack) rack.instance_eval do use Rack::InternalErrorCatcher if Backend.production? Backend::Logging::External.setup_rack self # Notice that this cannot be specified via config, it needs to be an # ENV because the metric server is started in Puma/Falcon # "before_fork" and the configuration is not loaded at that point. if ENV['CONFIG_LISTENER_PROMETHEUS_METRICS_ENABLED'].to_s.downcase.freeze == 'true'.freeze use Rack::Prometheus end loggers = Backend.configuration.request_loggers log_writers = Backend::Logging::Middleware.writers loggers use Backend::Logging::Middleware, writers: log_writers map "/internal" do require_relative "#{Backend::Util.root_dir}/app/api/api" internal_api = Backend::API::Internal.new( username: Backend.configuration.internal_api.user, password: Backend.configuration.internal_api.password, allow_insecure: !Backend.production? ) use ::Rack::Auth::Basic do |username, password| internal_api.helpers.check_password username, password end if internal_api.helpers.credentials_set? run internal_api end run Backend::Listener.new end end |