| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
IHP.FrameworkConfig
Synopsis
- module IHP.FrameworkConfig.Types
- option :: Typeable option => option -> StateT TMap IO ()
- addInitializer :: ((?context :: FrameworkConfig, ?modelContext :: ModelContext) => IO ()) -> StateT TMap IO ()
- findOption :: Typeable option => StateT TMap IO option
- findOptionOrNothing :: Typeable option => StateT TMap IO (Maybe option)
- ihpDefaultConfig :: ConfigBuilder
- buildFrameworkConfig :: ConfigBuilder -> IO FrameworkConfig
- defaultIHPSessionCookie :: Text -> SetCookie
- data RootApplication = RootApplication
- defaultPort :: Int
- defaultDatabaseUrl :: HasCallStack => IO ByteString
- defaultLoggerForEnv :: HasCallStack => Environment -> IO Logger
- isEnvironment :: (?context :: context, ConfigProvider context) => Environment -> Bool
- isDevelopment :: (?context :: context, ConfigProvider context) => Bool
- isProduction :: (?context :: context, ConfigProvider context) => Bool
- defaultCorsResourcePolicy :: Maybe CorsResourcePolicy
- withFrameworkConfig :: ConfigBuilder -> (FrameworkConfig -> IO result) -> IO result
- configIO :: (MonadIO monad, HasCallStack) => IO result -> monad result
- data ExceptionWithCallStack = ExceptionWithCallStack CallStack SomeException
Re-exports from IHP.FrameworkConfig.Types
module 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!")defaultIHPSessionCookie :: Text -> SetCookie Source #
Returns the default IHP session cookie configuration. Useful when you want to override the default settings in sessionCookie
data RootApplication Source #
Constructors
| RootApplication |
Instances
| Show RootApplication Source # | |
Defined in IHP.FrameworkConfig Methods showsPrec :: Int -> RootApplication -> ShowS # show :: RootApplication -> String # showList :: [RootApplication] -> ShowS # | |
| Eq RootApplication Source # | |
Defined in IHP.FrameworkConfig Methods (==) :: RootApplication -> RootApplication -> Bool # (/=) :: RootApplication -> RootApplication -> Bool # | |
defaultPort :: Int Source #
defaultLoggerForEnv :: HasCallStack => Environment -> IO Logger Source #
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 hereconfigIO :: (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.
data ExceptionWithCallStack Source #
Wraps an Exception thrown during the config process, but adds a CallStack
Inspired by https://maksbotan.github.io/posts/2021-01-20-callstacks.html
Constructors
| ExceptionWithCallStack CallStack SomeException |
Instances
| Exception ExceptionWithCallStack Source # | |
Defined in IHP.FrameworkConfig | |
| Show ExceptionWithCallStack Source # | |
Defined in IHP.FrameworkConfig Methods showsPrec :: Int -> ExceptionWithCallStack -> ShowS # show :: ExceptionWithCallStack -> String # showList :: [ExceptionWithCallStack] -> ShowS # | |
Orphan instances
| EnvVarReader AppPort Source # | |
Methods envStringToValue :: ByteString -> Either Text AppPort Source # | |
| EnvVarReader IPAddrSource Source # | |
Methods envStringToValue :: ByteString -> Either Text IPAddrSource Source # | |