yesod-1.6.0: Creation of type-safe, RESTful web applications.

Safe Haskell | None
Language | Haskell98

Yesod.Default.Config2

Contents

- Locally defined
- Re-exports from Data.Yaml.Config
- For backwards compatibility

Description

Some next-gen helper functions for the scaffolding's configuration system.

Synopsis

- configSettingsYml :: FilePath
- getDevSettings :: Settings -> IO Settings
- develMainHelper :: IO (Settings, Application) -> IO ()
- makeYesodLogger :: LoggerSet -> IO Logger
- applyCurrentEnv :: Bool -> Value -> IO Value
- getCurrentEnv :: IO (HashMap Text Text)
- applyEnvValue :: Bool -> HashMap Text Text -> Value -> Value
- loadYamlSettings :: FromJSON settings => [FilePath] -> [Value] -> EnvUsage -> IO settings
- loadYamlSettingsArgs :: FromJSON settings => [Value] -> EnvUsage -> IO settings
- data EnvUsage
- ignoreEnv :: EnvUsage
- useEnv :: EnvUsage
- requireEnv :: EnvUsage
- useCustomEnv :: HashMap Text Text -> EnvUsage
- requireCustomEnv :: HashMap Text Text -> EnvUsage
- newtype MergedValue = MergedValue {
  - getMergedValue :: Value
  }
- loadAppSettings :: FromJSON settings => [FilePath] -> [Value] -> EnvUsage -> IO settings
- loadAppSettingsArgs :: FromJSON settings => [Value] -> EnvUsage -> IO settings

# Locally defined

configSettingsYml :: FilePath Source #

Location of the default config file.

getDevSettings :: Settings -> IO Settings Source #

Helper for getApplicationDev in the scaffolding. Looks up PORT and DISPLAY_PORT and prints appropriate messages.

develMainHelper :: IO (Settings, Application) -> IO () Source #

Helper for develMain in the scaffolding.

makeYesodLogger :: LoggerSet -> IO Logger Source #

Create a `Logger` value (from yesod-core) out of a `LoggerSet` (from fast-logger).

# Re-exports from Data.Yaml.Config

applyCurrentEnv Source #

Arguments

:: Bool | require an environment variable to be present?
-> Value |
-> IO Value |

A convenience wrapper around `applyEnvValue` and `getCurrentEnv`

Since: yaml-0.8.16

getCurrentEnv :: IO (HashMap Text Text) Source #

Get the actual environment as a `HashMap` from `Text` to `Text`.

Since: yaml-0.8.16

applyEnvValue Source #

Arguments

:: Bool | require an environment variable to be present?
-> HashMap Text Text |
-> Value |
-> Value |

Override environment variable placeholders in the given `Value` with values from the environment.

If the first argument is `True`, then all placeholders _must_ be provided by the actual environment. Otherwise, default values from the `Value` will be used.

Since: yaml-0.8.16

loadYamlSettings Source #

Arguments

:: FromJSON settings |
=> [FilePath] | run time config files to use, earlier files have precedence
-> [Value] | any other values to use, usually from compile time config. overridden by files
-> EnvUsage |
-> IO settings |

Load the settings from the following three sources:

- Run time config files
- Run time environment variables
- The default compile time config file

For example, to load up settings from `config/foo.yaml` and allow overriding from the actual environment, you can use:

    loadYamlSettings ["config/foo.yaml"] [] useEnv

Since: yaml-0.8.16

loadYamlSettingsArgs Source #

Arguments

:: FromJSON settings |
=> [Value] | any other values to use, usually from compile time config. overridden by files
-> EnvUsage | use environment variables
-> IO settings |

Same as `loadYamlSettings`, but get the list of runtime config files from the command line arguments.

Since: yaml-0.8.17

data EnvUsage Source #

Defines how we want to use the environment variables when loading a config file. Use the smart constructors provided by this module.

Since: yaml-0.8.16

ignoreEnv :: EnvUsage Source #

Do not use any environment variables, instead relying on defaults values in the config file.

Since: yaml-0.8.16

useEnv :: EnvUsage Source #

Use environment variables when available, otherwise use defaults.

Since: yaml-0.8.16

requireEnv :: EnvUsage Source #

Do not use default values from the config file, but instead take all overrides from the environment. If a value is missing, loading the file will throw an exception.

Since: yaml-0.8.16

useCustomEnv :: HashMap Text Text -> EnvUsage Source #

Same as `useEnv`, but instead of the actual environment, use the provided `HashMap` as the environment.

Since: yaml-0.8.16

requireCustomEnv :: HashMap Text Text -> EnvUsage Source #

Same as `requireEnv`, but instead of the actual environment, use the provided `HashMap` as the environment.

Since: yaml-0.8.16

# For backwards compatibility

newtype MergedValue Source #

Constructors

MergedValue |

Fields

- getMergedValue :: Value

Instances

Semigroup MergedValue Source # |
Instance details Defined in Yesod.Default.Config2 Methods (<>) :: MergedValue -> MergedValue -> MergedValue Source # sconcat :: NonEmpty MergedValue -> MergedValue Source # stimes :: Integral b => b -> MergedValue -> MergedValue Source #

loadAppSettings Source #

Arguments

:: FromJSON settings |
=> [FilePath] | run time config files to use, earlier files have precedence
-> [Value] | any other values to use, usually from compile time config. overridden by files
-> EnvUsage |
-> IO settings |

Deprecated: Use loadYamlSettings

Load the settings from the following three sources:

- Run time config files
- Run time environment variables
- The default compile time config file

loadAppSettingsArgs Source #

Arguments

:: FromJSON settings |
=> [Value] | any other values to use, usually from compile time config. overridden by files
-> EnvUsage | use environment variables
-> IO settings |

Deprecated: Use loadYamlSettingsArgs

Same as `loadAppSettings`, but get the list of runtime config files from the command line arguments.