module Utopia
Classes and Modules
class Application < Protocol::HTTP::MiddlewareThe protocol-facing entrypoint for a Utopia application.
class ComponentsInstalls JavaScript packages into the public components directory. Package contents are copied from
distwhen it exists, otherwise from the package root.module ContentBuilds middleware for serving filesystem-backed dynamic content.
module ControllerA middleware which loads controller classes and invokes functionality based on the requested path.
module ExceptionsMiddleware for handling exceptional situations.
module HTTPHTTP protocol implementation.
class ImportMapRepresents an import map for JavaScript modules with support for URI and relative path resolution. Import maps allow you to control how JavaScript imports are resolved, supporting both absolute URLs and relative paths with proper context-aware resolution.
module LocalizationComputes request localization preferences and resolves localized resources.
class PathRepresents a path as an array of path components. Useful for efficient URL manipulation.
module RedirectionA middleware which assists with redirecting from one path to another.
class RequestUtopia's application-facing request wrapper.
module ResponseResponse helpers for Utopia applications.
module SessionProvides cookie-backed session middleware.
class SetupUsed for setting up a Utopia web application, typically via
config/environment.rbclass ShellThis is designed to be used with the corresponding bake task.
module StaticA middleware which serves static files from the specified root directory.
Definitions
PAGES_PATH = "pages".freeze
The default pages path for module Utopia::Content middleware.
def self.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd)
The default root directory for middleware to operate within, e.g. the web-site directory. Convention over configuration.
Implementation
def self.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd)
File.expand_path(subdirectory, pwd)
end
def self.default_path(*arguments)
The same as Utopia.default_root but returns an instance of class Utopia::Path.
Implementation
def self.default_path(*arguments)
Path[default_root(*arguments)]
end
def self.Path(path)
Coerce a value into a class Utopia::Path.
Signature
-
parameter
pathUtopia::Path | String The path.
-
returns
Path | Nil The coerced path.
Implementation
def self.Path(path)
Path.create(path)
end
def self.setup(root = nil, **options)
You can call this method exactly once per process.
Implementation
def self.setup(root = nil, **options)
if @setup
raise RuntimeError, "Utopia already setup!"
end
# We extract the root from the caller of this method:
if root.nil?
config_root = File.dirname(caller[0])
root = File.dirname(config_root)
end
@setup = Setup.new(root, **options)
@setup.apply!
return @setup
end