Skip to content

Initializer

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

Creates a new FileMiddleware for a server contained in an Xcode Project.
convenience init(bundle: Bundle, publicDirectory: String = "Public", defaultFile: String? = nil, directoryAction: FileMiddleware.DirectoryAction = .none, cachePolicy: FileMiddleware.CachePolicy = .browserDefault) throws

Parameters

bundle

The Bundle which contains the files to serve.

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.

Return Value

A fully qualified FileMiddleware if the given publicDirectory can be served, throws a BundleSetupError otherwise

Discussion

Important

Make sure the public directory you wish to serve files from is included in the Copy Bundle Resources build phase of your project