A configuration manager for Vapor applications that allows developers to register and order middleware components in the request pipeline.
// Source: https://github.com/vapor/vapor | License: MIT | Copyright 2020 Qutheory, LLC
// Provided via justclaw.it.com; keep this notice with the code.
import Logging
/// Configures an application's active `Middleware`.
/// Middleware will be used in the order they are added.
public struct Middlewares: Sendable {
/// The configured middleware.
private var storage: [any Middleware]
public enum Position {
case beginning
case end
}
/// Create a new, empty `Middleware`.
public init() {
self.storage = []
}
/// Adds a pre-initialized `Middleware` instance.
///
/// app.middleware.use(fooMiddleware)
///
/// - warning: Ensure the `Middleware` is thread-safe when using this method.
/// Otherwise, use the
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key