ihp-1.4.0: Haskell Web Framework
Safe HaskellNone
LanguageGHC2021

IHP.FrameworkConfig

Synopsis

Re-exports from IHP.FrameworkConfig.Types

Configuration helpers

option :: Typeable option => option -> StateT TMap IO () Source #

Puts an option into the current configuration

In case an option already exists with the same type, it will not be overriden:

option Production
option Development
findOption @Environment

This code will return Production as the second call to option is ignored to not override the existing option.

addInitializer :: ((?context :: FrameworkConfig, ?modelContext :: ModelContext) => IO ()) -> StateT TMap IO () Source #

Adds a callback to be run during startup of the app server

The follwoing example will print a hello world message on startup:

config = do
    addInitializer (putStrLn "Hello World!")

findOption :: Typeable option => StateT TMap IO option Source #

findOptionOrNothing :: Typeable option => StateT TMap IO (Maybe option) Source #

defaultIHPSessionCookie :: Text -> SetCookie Source #

Returns the default IHP session cookie configuration. Useful when you want to override the default settings in sessionCookie

isEnvironment :: (?context :: context, ConfigProvider context) => Environment -> Bool Source #

isDevelopment :: (?context :: context, ConfigProvider context) => Bool Source #

Returns True when the application is running in Development mode

Development mode means that the Development option is configured in Config/Config.hs

See Environment for documentation on the default differences.

isProduction :: (?context :: context, ConfigProvider context) => Bool Source #

Returns True when the application is running in Production mode

Production mode means that the Production option is configured in Config/Config.hs

See Environment for documentation on the default differences.

withFrameworkConfig :: ConfigBuilder -> (FrameworkConfig -> IO result) -> IO result Source #

Builds a config and calls the provided callback.

Once the callback has returned the resources allocated by the config are closed. Specifcally this will close open log file handles.

Example:

import Config (config)

withFrameworkConfig config \frameworkConfig -> do
    -- Do something with the FrameworkConfig here

configIO :: (MonadIO monad, HasCallStack) => IO result -> monad result Source #

Runs IO inside the config process

It works like liftIO, but attaches a CallStack on error. Without this it would be hard to see where an error during the config setup comes from.

All call-sites of this function should also have a HasCallStack constraint to provide helpful information in the call stack.

See https://github.com/digitallyinduced/ihp/issues/1503

Orphan instances