Options
public struct Options
Configuration options for StaticFileServer.
-
Initialize an Options instance.
Declaration
Swift
public init(possibleExtensions: [String] = [], serveIndexForDirectory: Bool = true, redirect: Bool = true, cacheOptions: CacheOptions = CacheOptions(), acceptRanges: Bool = true, defaultIndex: String? = nil)Parameters
possibleExtensionsan array of file extensions to be added to the file name in case the file was not found. The extensions are added in the order they appear in the array, and a new search is performed.
serveIndexForDirectoryan indication whether to serve “index.html” file the requested path is a directory.
redirectan indication whether to redirect to trailing “/” when the requested path is a directory.
cacheOptionscache options for StaticFileServer.
defaultIndexA default index, like “/index.html”, to be served if the requested path is not found. This is intended to be used by single page applications that wish to fallback to a default index when a requested path is not found, and where that path is not a file request. It will be assumed that the default index is reachable from the root directory configured with the StaticFileServer. Here’s a usage example:
swift let router = Router() router.all("/", middleware: StaticFileServer(defaultIndex: "/index.html"))
View on GitHub
Options Structure Reference