init(rootDirectory : URL, port: Int) init(rootCreates a new preview server.
An HTTP/1.1 server for previewing static documentation locally.
actor PreviewServerThis actor provides a simple, development-focused HTTP server that serves files from a specified directory. It uses SwiftNIO with async/await for modern Swift concurrency support.
Preview is designed for local development use only. It binds to localhost and serves static files without TLS encryption. The server uses NIOAsync to bridge NIO’s event-driven architecture with Swift’s structured concurrency.
Create a server instance and call run() to start serving:
let server = PreviewServer(
rootDirectory: URL(fileURLWithPath: "/path/to/docs"),
port: 8080
)
try await server.run()
The server runs until the process is terminated (typically via Ctrl+C).
init(rootDirectory : URL, port: Int) init(rootfunc run() async throws run()let rootDirectory : URL rootlet port: Int portSwift.Sendable Swift.SendableMetatype _Concurrency.Actor