StaticFileServer

open class StaticFileServer: RouterMiddleware

A router middleware that serves static files from a given path.

  • Cache configuration options for StaticFileServer.

    See more

    Declaration

    Swift

    public struct CacheOptions
  • Configuration options for StaticFileServer.

    See more

    Declaration

    Swift

    public struct Options
  • Undocumented

    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.