StaticFileServer
open class StaticFileServer: RouterMiddleware
A router middleware that serves static files from a given path.
-
Cache configuration options for StaticFileServer.
See moreDeclaration
Swift
public struct CacheOptions
-
Configuration options for StaticFileServer.
See moreDeclaration
Swift
public struct Options
-
The absolute (fully qualified) root serving path for this
StaticFileServer
, for example:/Users/Dave/MyKituraProj/./public
Declaration
Swift
public let absoluteRootPath: String
-
Initializes a
StaticFileServer
instance.Declaration
Swift
public init(path: String = "./public", options: Options = Options(), customResponseHeadersSetter: ResponseHeadersSetter? = nil)
Parameters
path
a root directory for file serving.
options
configuration options for StaticFileServer.
customResponseHeadersSetter
an object of a class that implements
ResponseHeadersSetter
protocol providing a custom method to set the headers of the response. -
Handle the request - serve static file.
Declaration
Swift
open func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void)
Parameters
request
The
RouterRequest
object used to work with the incoming HTTP request.response
The
RouterResponse
object used to respond to the HTTP request.next
The closure called to invoke the next handler or middleware associated with the request.