asyncBoot
Called when the applications starts up, will trigger the lifecycle handlers. The asynchronous version of boot
func asyncBoot() async throws
Called when the applications starts up, will trigger the lifecycle handlers. The asynchronous version of boot
func asyncBoot() async throws
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.
final class Application
Core type representing a Vapor application.
func boot() throws
static func make(_ environment: Environment = .development, _ eventLoopGroupProvider: EventLoopGroupProvider = .singleton) async throws -> Application
var allocator: ByteBufferAllocator { get }
var asyncCommands: AsyncCommands { get set }
var cache: Cache { get }
Current application cache. See Request.cache
for caching in request handlers.
var caches: Caches { get }
Controls application’s configured caches.
var client: Client { get }
var clients: Clients { get }
var commands: Commands { get set }
var console: Console { get set }
var didShutdown: Bool { get }
var directory: DirectoryConfiguration { get set }
var environment: Environment { get set }
let eventLoopGroup: EventLoopGroup
let eventLoopGroupProvider: EventLoopGroupProvider
var fileio: NonBlockingFileIO { get }
var http: HTTP { get }
var lifecycle: Lifecycle { get set }
var locks: Locks { get set }
var logger: Logger { get set }
var middleware: Middlewares { get set }
var password: Password { get }
var passwords: Passwords { get }
var responder: Responder { get }
var routes: Routes { get }
var running: Running? { get set }
var server: Server { get }
var servers: Servers { get }
var services: Services { get }
var sessions: Sessions { get }
var storage: Storage { get set }
var sync: NIOLock { get }
var threadPool: NIOThreadPool { get set }
The application thread pool. Vapor uses NIOSingletons.posixBlockingThreadPool
by default for this, which defaults to a thread pool of size equal to the number of available cores.
var traceAutoPropagation: Bool { get set }
If enabled, tracing propagation is automatically handled by restoring & setting request.serviceContext
automatically across Vapor-internal EventLoopFuture boundaries. If disabled, traces will not automatically nest, and the user should restore & set request.serviceContext
manually where needed. There are performance implications to enabling this feature.
var view: ViewRenderer { get }
var views: Views { get }
func add(_ route: Route)
func asyncShutdown() async throws
func execute() async throws
Starts the Application
asynchronous using the startup
method, then waits for any running tasks to complete. If your application is started without arguments, the default argument is used.
func run() throws
Starts the Application
using the start
method, then waits for any running tasks to complete. If your application is started without arguments, the default argument is used.
func shutdown()
func start() throws
When called, this will execute the startup command provided through an argument. If no startup command is provided, the default is used. Under normal circumstances, this will start running Vapor’s webserver.
func startup() async throws
When called, this will asynchronously execute the startup command provided through an argument. If no startup command is provided, the default is used. Under normal circumstances, this will start running Vapor’s webserver.
struct Caches
struct Clients
struct Core
enum EventLoopGroupProvider
struct HTTP
struct Lifecycle
final class Locks
struct Password
struct Passwords
struct Responder
struct Running
struct Servers
struct Service<ServiceType>
struct Services
struct Sessions
struct Views
convenience init(_ environment: Environment = .development, _ eventLoopGroupProvider: EventLoopGroupProvider = .singleton)