class Falcon::Server
A server listening on a specific endpoint, hosting a specific middleware.
def self.middleware(rack_app, verbose: false, cache: true)
@parameter verbose [Boolean] Whether to add the {Middleware::Verbose} middleware.
@parameter rack_app [Proc | Object] A rack application/middleware.
Wrap a rack application into a middleware suitable the server.
def self.middleware(rack_app, verbose: false, cache: true) ::Protocol::HTTP::Middleware.build do if verbose use Middleware::Verbose end if cache use Async::HTTP::Cache::General end use ::Protocol::HTTP::ContentEncoding use ::Protocol::Rack::Adapter run rack_app end end
def accept(...)
def accept(...) @accept_count += 1 @connection_count += 1 super ensure @connection_count -= 1 end
def call(...)
def call(...) @request_count += 1 @active_count += 1 super ensure @active_count -= 1 end
def format_count(value)
def format_count(value) if value > 1_000_000 "#{(value/1_000_000.0).round(2)}M" elsif value > 1_000 "#{(value/1_000.0).round(2)}K" else value end end
def initialize(...)
def initialize(...) super @accept_count = 0 @connection_count = 0 @request_count = 0 @active_count = 0 end
def statistics_string
def statistics_string "C=#{format_count @connection_count}/#{format_count @accept_count} R=#{format_count @active_count}/#{format_count @request_count}" end