yesod-default-0.5.0: Default config and main functions for your yesod application

Yesod.Default.Config

Synopsis

Documentation

data DefaultEnv Source

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

fromArgs :: IO (AppConfig DefaultEnv ())Source

Load an AppConfig using the DefaultEnv environments from commandline arguments.

fromArgsExtra :: (DefaultEnv -> TextObject -> IO extra) -> IO (AppConfig DefaultEnv extra)Source

Same as fromArgs, but allows you to specify how to parse the appExtra record.

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

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

Instances

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

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.

csLoadExtra :: environment -> TextObject -> IO 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 -> TextObject -> IO TextObject

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

   -- ssl: will default false
   -- approot: will default to "http://localhost:3000"
 -- typical outward-facing production box
 Production:
   host: www.example.com

   -- ssl: will default false
   -- port: will default 80
   -- 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"

 -- approot is specified so that the non-80 port is not appended
 -- automatically.

withYamlEnvironmentSource

Arguments

:: Show e 
=> FilePath

the yaml file

-> e

the environment you want to load

-> (TextObject -> IO a)

what to do with the mapping

-> IO a 

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

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