module Application
Represents the environment configuration for a Lively application server.
This module provides server configuration including URL binding, process count, application class resolution, and middleware stack setup. It integrates with Falcon's server environment to provide a complete hosting solution.
Definitions
def url
Get the server URL for this application.
Signature
-
returns
String
The base URL where the server will be accessible.
Implementation
def url
"http://localhost:9292"
end
def count
Get the number of server processes to run.
Signature
-
returns
Integer
The number of worker processes.
Implementation
def count
1
end
def application
Resolve the application class to use.
Signature
-
returns
Class
The application class, either user-defined or default.
Implementation
def application
if Object.const_defined?(:Application)
Object.const_get(:Application)
else
Console.warn(self, "No Application class defined, using default.")
::Lively::Application
end
end
def middleware
Build the middleware stack for this application.
Signature
-
returns
Protocol::HTTP::Middleware
The complete middleware stack.
Implementation
def middleware
::Protocol::HTTP::Middleware.build do |builder|
builder.use Lively::Assets, root: File.expand_path("public", self.root)
builder.use Lively::Assets, root: File.expand_path("../../../public", __dir__)
builder.use self.application
end
end