Skip to content

Initializer

init(publicDirectory:defaultFile:directoryAction:advancedETagComparison:cachePolicy:)

Creates a new FileMiddleware.
init(publicDirectory: String, defaultFile: String? = nil, directoryAction: FileMiddleware.DirectoryAction = .none, advancedETagComparison: Bool = false, cachePolicy: FileMiddleware.CachePolicy = .browserDefault)

Parameters

publicDirectory

The public directory to serve files from.

defaultFile

The name of the default file to look for and serve if a request hits any public directory. Starting with / implies an absolute path from the public directory root. If nil, no default files are served.

directoryAction

Determines the action to take when the request doesn’t have a trailing slash but matches a directory.

advancedETagComparison

The method used when ETags are generated. If true, a byte-by-byte hash is created (and cached), otherwise a simple comparison based on the file’s last modified date and size.