FileMiddleware
Serves static files from a public directory.
final class FileMiddleware
FileMiddleware
will default to DirectoryConfig
’s working directory with "/Public"
appended.
Serves static files from a public directory.
final class FileMiddleware
FileMiddleware
will default to DirectoryConfig
’s working directory with "/Public"
appended.
import Vapor
Vapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
protocol AsyncMiddleware : Middleware
AsyncMiddleware
is placed between the server and your router. It is capable of mutating both incoming requests and outgoing responses. AsyncMiddleware
can choose to pass requests on to the next AsyncMiddleware
in a chain, or they can short circuit and return a custom Response
if desired.
@preconcurrency protocol Middleware : Sendable
Middleware
is placed between the server and your router. It is capable of mutating both incoming requests and outgoing responses. Middleware
can choose to pass requests on to the next Middleware
in a chain, or they can short circuit and return a custom Response
if desired.
protocol Sendable
convenience init(bundle: Bundle, publicDirectory: String = "Public", defaultFile: String? = nil, directoryAction: DirectoryAction = .none, cachePolicy: CachePolicy = .browserDefault) throws
Creates a new FileMiddleware
for a server contained in an Xcode Project.
init(publicDirectory: String, defaultFile: String? = nil, directoryAction: DirectoryAction = .none, advancedETagComparison: Bool = false, cachePolicy: CachePolicy = .browserDefault)
Creates a new FileMiddleware
.
func respond(to request: Request, chainingTo next: any AsyncResponder) async throws -> Response
struct BundleSetupError
struct CachePolicy
The browser cache policy files should be served with.
struct DirectoryAction
Possible actions to take when the request doesn’t have a trailing slash but matches a directory
func makeResponder(chainingTo responder: Responder) -> Responder
Wraps a Responder
in a single Middleware
creating a new Responder
.
func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response>