init(publicDirectory:defaultFile:directoryAction:advancedETagComparison:cachePolicy:)
Creates a new FileMiddleware
.
init(publicDirectory: String, defaultFile: String? = nil, directoryAction: DirectoryAction = .none, advancedETagComparison: Bool = false, cachePolicy: 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. Ifnil
, 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.
- cacheControl
Specifies the browser’s cache policy that should be used for all files. Defaults to the browser’s default behavior
browserDefault
.