conferer-0.3.0.0: Configuration management library

Safe HaskellSafe
LanguageHaskell2010

Conferer.Provider.Env

Contents

Synopsis

Env Provider

This Provider provides config values from env vars given a prefix that's used to avoid colliding with different system configuration

For example if you use the Prefix "awesomeapp" and get the Key "warp.port" this provider will try to lookup the env var called AWESOMEAPP_WARP_PORT.

Usage

To use this provider simply choose a prefix and add it using the addProvider function like:

config & addProvider (mkEnvProvider "awesomeapp")

mkEnvProvider' :: LookupEnvFunc -> Prefix -> ProviderCreator Source #

ProviderCreator for env Provider that allows parameterizing the function used to lookup for testing

type Prefix = Text Source #

A text to namespace env vars

type LookupEnvFunc = String -> IO (Maybe String) Source #

Type alias for the function to lookup env vars

keyToEnvVar :: Prefix -> Key -> Text Source #

Get the env name from a prefix and a key by uppercasing and intercalating underscores

>>> keyToEnVar "awesomeapp" "warp.port"
"AWESOMEAPP_WARP_PORT"