Skip to content

StaticFileMiddleware

Josh Wright edited this page Jan 14, 2021 · 4 revisions

StaticFileMiddleware

Middleware for serving static files from a given directory.

public struct StaticFileMiddleware: Middleware

Usage:

self.router.globalMiddlewares = [
    // Will server static files from the 'Public' directory of
    // your project.
    StaticFileMiddleware(from: "Public")
]

Now your router will serve the files that are in the Public directory.

Inheritance

Middleware

Initializers

init(from:)

Creates a new middleware to serve static files from a given directory. Directory defaults to "public/".

public init(from directory: String = "Public/")

Parameters

  • directory: The directory to server static files from. Defaults to "Public/".

Methods

intercept(_:next:)

public func intercept(_ request: Request, next: @escaping Next) throws -> EventLoopFuture<Response>
Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally