init(rootDirectory : URL) init(rootCreates a new static file handler.
Handler for serving static files from a directory.
struct StaticFileHandlerThis type provides secure file serving with path sanitisation to prevent directory traversal attacks. It supports automatic index file resolution for directory requests.
Static validates and sanitises all incoming request paths, ensuring they remain within the configured root directory. Directory requests are automatically redirected to index if present.
The handler implements several security measures:
Path normalisation to prevent .. traversal
Verification that resolved paths stay within the root directory
URL decoding with malformed input rejection
Query string stripping
init(rootDirectory : URL) init(rootfunc handleRequest (uri: String, includeBody : Bool) async -> HTTPResponse handlelet rootDirectory : URL rootSwift.Sendable Swift.SendableMetatype