module Fiona7 module Middleware class ServerDetectionMiddleware class << self attr_accessor :server_detected attr_accessor :server_name, :server_port def server_detected? !!server_detected end end self.server_detected = false def initialize(app) @app = app end def call(env) self.class.server_detected = true self.class.server_name = env['SERVER_NAME'] self.class.server_port = (env['SERVER_PORT'].presence || 80).to_i @app.call(env) end end end end