Structure
Environment
The environment the application is running in, i.e., production, dev, etc. All
Containers will have an Environment that can be used to dynamically register and configure services.struct Environment
Overview
switch env {
case .production:
app.http.server.configuration = ...
default: break
}
The Environment can also be used to retrieve variables from the Process’ ENV.
print(Environment.get("DB_PASSWORD"))
Topics
Structures
struct ProcessThe process information of an environment. WrapsProcessInto.processInfo.
Operators
Initializers
init(name: String)Create a newEnvironment.
Instance Properties
var isRelease: Booltrueif this environment is meant for production use cases.let name: StringThe environment’s unique name.
Type Properties
static var development: EnvironmentAn environment for developing your application.static var process: ProcessThe current process of the environment.static var production: EnvironmentAn environment for deploying your application to consumers.static var testing: EnvironmentAn environment for testing your application.
Type Methods
static func custom(name: String) -> EnvironmentCreates a custom environment.static func detect(from: ConfigReader) throws -> EnvironmentDetects the environment fromConfigReader. Parses thevapor.envflag.static func get(String) -> String?Gets a key from the process environmentstatic func secret(key: String) async throws -> String?Reads a file’s content for a secret. The secret key is the name of the environment variable that is expected to specify the path of the file containing the secret.static func secret(path: String) async throws -> String?Load the content of a file at a given path as a secret.
Default Implementations
Relationships
Conforms To
Configuration.ExpressibleByConfigStringSwift.CopyableSwift.CustomStringConvertibleSwift.EquatableSwift.EscapableSwift.SendableSwift.SendableMetatype