yesod-1.6.2: Creation of type-safe, RESTful web applications.
Safe HaskellNone
LanguageHaskell2010

Yesod.Default.Config

Synopsis

Documentation

data DefaultEnv Source #

A yesod-provided AppEnv, allows for Development, Testing, and Production environments

fromArgs :: (Read env, Show env, Enum env, Bounded env) => (env -> Object -> Parser extra) -> IO (AppConfig env extra) Source #

Load the app config from command line parameters

fromArgsSettings :: (Read env, Show env, Enum env, Bounded env) => (env -> IO (ConfigSettings env extra)) -> IO (AppConfig env extra) Source #

Load the app config from command line parameters, using the given @ConfigSettings.

Since 1.2.2

loadDevelopmentConfig :: IO (AppConfig DefaultEnv ()) Source #

Load your development config (when using DefaultEnv)

data AppConfig environment extra Source #

Dynamic per-environment configuration which can be loaded at run-time negating the need to recompile between environments.

Constructors

AppConfig 

Fields

Instances

Instances details
(Show environment, Show extra) => Show (AppConfig environment extra) Source # 
Instance details

Defined in Yesod.Default.Config

Methods

showsPrec :: Int -> AppConfig environment extra -> ShowS #

show :: AppConfig environment extra -> String #

showList :: [AppConfig environment extra] -> ShowS #

data ConfigSettings environment extra Source #

Constructors

ConfigSettings 

Fields

  • csEnv :: environment

    An arbitrary value, used below, to indicate the current running environment. Usually, you will use DefaultEnv for this type.

  • csParseExtra :: environment -> Object -> Parser extra

    Load any extra data, to be used by the application.

  • csFile :: environment -> IO FilePath

    Return the path to the YAML config file.

  • csGetObject :: environment -> Value -> IO Value

    Get the sub-object (if relevant) from the given YAML source which contains the specific settings for the current environment.

configSettings :: Show env => env -> ConfigSettings env () Source #

Default config settings.

loadConfig :: ConfigSettings environment extra -> IO (AppConfig environment extra) Source #

Load an AppConfig.

Some examples:

-- typical local development
Development:
  host: localhost
  port: 3000

  -- approot: will default to ""
-- typical outward-facing production box
Production:
  host: www.example.com

  -- port: will default 80
  -- host: will default to "*"
  -- approot: will default "http://www.example.com"
-- maybe you're reverse proxying connections to the running app
-- on some other port
Production:
  port: 8080
  approot: "http://example.com"
  host: "localhost"

withYamlEnvironment Source #

Arguments

:: Show e 
=> FilePath

the yaml file

-> e

the environment you want to load

-> (Value -> Parser a)

what to do with the mapping

-> IO a 

Loads the configuration block in the passed file named by the passed environment, yields to the passed function as a mapping.

Errors in the case of a bad load or if your function returns Nothing.