Vapor Documentation

Class Application

public final class Application  

Core type representing a Vapor application.

%765 Application Application RoutesBuilder RoutesBuilder Application->RoutesBuilder

Nested Types

Application.Lifecycle
Application.Locks
Application.EventLoopGroupProvider
Application.Caches
Application.Clients
Application.Core
Application.Running
Application.HTTP
Application.Password
Application.Passwords
Application.Responder
Application.Servers
Application.Sessions
Application.Views

Conforms To

RoutesBuilder

Initializers

init(_:​_:​)

public init(
        _ environment: Environment = .development,
        _ eventLoopGroupProvider: EventLoopGroupProvider = .createNew
    )  

Properties

environment

public var environment: Environment

event​Loop​Group​Provider

public let eventLoopGroupProvider: EventLoopGroupProvider

event​Loop​Group

public let eventLoopGroup: EventLoopGroup

storage

public var storage: Storage

did​Shutdown

public private(set) var didShutdown: Bool

logger

public var logger: Logger

lifecycle

public var lifecycle: Lifecycle

locks

public var locks: Locks

sync

public var sync: Lock  

caches

public var caches: Caches  

Controls application's configured caches.

app.caches.use(.memory)

cache

public var cache: Cache  

Current application cache. See Request.cache for caching in request handlers.

clients

public var clients: Clients  

client

public var client: Client  

console

public var console: Console  

commands

public var commands: Commands  

thread​Pool

public var threadPool: NIOThreadPool  

The application thread pool. Vapor provides a thread pool with 64 threads by default.

It's possible to configure the thread pool size by overriding this value with your own thread pool.

application.threadPool = NIOThreadPool(numberOfThreads: 100)

If overridden, Vapor will take ownership of the thread pool and automatically start it and shut it down when needed.

fileio

public var fileio: NonBlockingFileIO  

allocator

public var allocator: ByteBufferAllocator  

running

public var running: Running?  

directory

public var directory: DirectoryConfiguration  

http

public var http: HTTP  

middleware

public var middleware: Middlewares  

password

public var password: Password  

passwords

public var passwords: Passwords  

responder

public var responder: Responder  

routes

public var routes: Routes  

servers

public var servers: Servers  

server

public var server: Server  

sessions

public var sessions: Sessions  

views

public var views: Views  

view

public var view: ViewRenderer  

Methods

run()

public 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.

Under normal circumstances, run() begin start the shutdown, then wait for the web server to (manually) shut down before returning.

start()

public 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.

If you start Vapor through this method, you'll need to prevent your Swift Executable from closing yourself. If you want to run your Application indefinitely, or until your code shuts the application down, use run() instead.

boot()

public func boot() throws  

shutdown()

public func shutdown()  

add(_:​)

public func add(_ route: Route)