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

Safe HaskellNone




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.




appEnv :: environment
appPort :: Int
appRoot :: Text
appHost :: HostPreference
appExtra :: extra


(Show environment, Show extra) => Show (AppConfig environment extra) 

data ConfigSettings environment extra Source




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
  host: localhost
  port: 3000

  -- approot: will default to ""
-- typical outward-facing production box

  -- port: will default 80
  -- host: will default to "*"
  -- approot: will default ""
-- maybe you're reverse proxying connections to the running app
-- on some other port
  port: 8080
  approot: ""
  host: "localhost"

withYamlEnvironment Source


:: 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.