Application
Application module is a building block which initializes the crucial parts of the web-framework, it contains the main handler stack and the HTTP server.
# Application is a building class that initializes the core components of the Grip web framework.
# It manages the main handler stack and the HTTP server.
class Application < Grip::Application
include Grip::Application
# List of HTTP handlers for processing incoming requests.
property handlers : Array(HTTP::Handler) = [] of HTTP::Handler
# Initializes the application
def initialize
end
# Defines the host address of the server.
# @return [String] The host address (e.g., "0.0.0.0").
def host : String
DEFAULT_HOST
end
# Defines the root path for routing (placeholder for custom implementation).
# @return [String] The root path for the application.
def root : String
"/"
end
# Placeholder for custom configuration or logic.
# @return [Nil] No return value by default.
def custom : Nil
nil
end
# Defines the port on which the server listens.
# @return [Int32] The port number (e.g., 4004).
def port : Int32
DEFAULT_PORT
end
# Determines if the server reuses the port.
# @return [Bool] True if port reuse is enabled, false otherwise.
def reuse_port : Bool
DEFAULT_REUSE_PORT
end
# Defines the SSL key file location for the application.
# @return [String] The path to the SSL key file, if set.
def key_file : String
ENV["KEY"]? || ""
end
# Defines the SSL certificate file location for the application.
# @return [String] The path to the SSL certificate file, if set.
def cert_file : String
ENV["CERTIFICATE"]? || ""
end
end
# Instantiates and starts the Grip application.
app = Application.new
app.run