api

http4k / org.http4k.cloudnative.env / Environment

Environment

interface Environment

This models the runtime environment of the shell where the app is running. Optionally pass a separator to use for multi-values otherwise a standard comma is used - this means you MUST override the separator if you have single values which contain commas, otherwise singular environment keys will just retrieve the first value.

Properties

Name Summary
separator open val separator: String

Functions

Name Summary
get abstract operator fun <T> get(key: Lens<Environment, T>): T
abstract operator fun get(key: String): String?
keys abstract fun keys(): Set<String>
minus abstract operator fun minus(key: String): Environment
overrides Overlays the configuration set in this Environment on top of the values in the passed Environment. Used to chain: eg. Local File -> System Properties -> Env Properties -> Defaultsopen infix fun overrides(that: Environment): Environment
set abstract operator fun set(key: String, value: String): Environment

Companion Object Properties

Name Summary
EMPTY val EMPTY: Environment
ENV Configuration from the runtime environmentval ENV: Environment
JVM_PROPERTIES Configuration from JVM properties (-D flags)val JVM_PROPERTIES: Environment

Companion Object Functions

Name Summary
defaults Setup default configuration mappings using EnvironmentKey lens bindingsfun defaults(vararg fn: (Environment) -> Environment): Environment
from Load configuration from standard Properties file format on diskfun from(file: File): Environmentfun from(vararg pairs: Pair<String, String>): Environment
fun from(env: Map<String, String>): Environment
fromResource Load configuration from standard Properties file format on classpathfun fromResource(resource: String): Environment

Extension Functions

Name Summary
with fun Environment.with(vararg modifiers: (Environment) -> Environment): Environment

Companion Object Extension Functions

Name Summary
fromConfigFile fun Environment.Companion.fromConfigFile(file: File): Environment
fromYaml Read a YAML file into environments, prepending all of the nested levels into the property namesfun Environment.Companion.fromYaml(file: File): Environment

Inheritors

Name Summary
MapEnvironment class MapEnvironment : Environment