Safe Haskell | None |
---|
Synopsis
- newtype AppHostname = AppHostname Text
- newtype AppPort = AppPort Int
- newtype BaseUrl = BaseUrl Text
- newtype RequestLoggerMiddleware = RequestLoggerMiddleware Middleware
- newtype SessionCookie = SessionCookie SetCookie
- newtype DBPoolIdleTime = DBPoolIdleTime NominalDiffTime
- newtype DBPoolMaxConnections = DBPoolMaxConnections Int
- newtype DatabaseUrl = DatabaseUrl ByteString
- type ConfigBuilder = StateT TMap IO ()
- newtype ExceptionTracker = ExceptionTracker {
- onException :: Maybe Request -> SomeException -> IO ()
- newtype IdeBaseUrl = IdeBaseUrl Text
- newtype RLSAuthenticatedRole = RLSAuthenticatedRole Text
- newtype AssetVersion = AssetVersion Text
- newtype CustomMiddleware = CustomMiddleware Middleware
- newtype DataSyncMaxSubscriptionsPerConnection = DataSyncMaxSubscriptionsPerConnection Int
- newtype DataSyncMaxTransactionsPerConnection = DataSyncMaxTransactionsPerConnection Int
- newtype Initializer = Initializer {
- onStartup :: (?context :: FrameworkConfig, ?modelContext :: ModelContext) => IO ()
- option :: Typeable option => option -> StateT TMap IO ()
- addInitializer :: ((?context :: FrameworkConfig, ?modelContext :: ModelContext) => IO ()) -> StateT TMap IO ()
- ihpDefaultConfig :: ConfigBuilder
- initAssetVersion :: ConfigBuilder
- findOption :: Typeable option => StateT TMap IO option
- findOptionOrNothing :: Typeable option => StateT TMap IO (Maybe option)
- buildFrameworkConfig :: ConfigBuilder -> IO FrameworkConfig
- data FrameworkConfig = FrameworkConfig {
- appHostname :: !Text
- environment :: !Environment
- appPort :: !Int
- baseUrl :: !Text
- requestLoggerMiddleware :: !Middleware
- sessionCookie :: !SetCookie
- mailServer :: !MailServer
- databaseUrl :: !ByteString
- dbPoolIdleTime :: !NominalDiffTime
- dbPoolMaxConnections :: !Int
- cssFramework :: !CSSFramework
- logger :: !Logger
- exceptionTracker :: !ExceptionTracker
- appConfig :: !TMap
- corsResourcePolicy :: !(Maybe CorsResourcePolicy)
- parseRequestBodyOptions :: !ParseRequestBodyOptions
- ideBaseUrl :: Text
- rlsAuthenticatedRole :: !Text
- assetVersion :: !Text
- assetBaseUrl :: !(Maybe Text)
- customMiddleware :: !CustomMiddleware
- initializers :: ![Initializer]
- type ConfigProvider context = HasField "frameworkConfig" context 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
- initModelContext :: FrameworkConfig -> IO ModelContext
- data ExceptionWithCallStack = ExceptionWithCallStack CallStack SomeException
- configIO :: (MonadIO monad, HasCallStack) => IO result -> monad result
Documentation
newtype AppHostname Source #
Instances
EnvVarReader AppPort Source # | |
Defined in IHP.FrameworkConfig |
newtype RequestLoggerMiddleware Source #
Provides IHP with a middleware to log requests and responses.
By default this uses the RequestLogger middleware from wai-extra. Take a look at the wai-extra documentation when you want to customize the request logging.
Set requestLoggerMiddleware = application -> application
to disable request logging.
RequestLoggerMiddleware Middleware |
newtype SessionCookie Source #
Provides the default settings for the session cookie.
- Max Age: 30 days
- Same Site Policy: Lax
- HttpOnly (no access through JS)
- secure, when baseUrl is a https url
Override this to set e.g. a custom max age or change the default same site policy.
Example: Set max age to 90 days > sessionCookie = defaultIHPSessionCookie { Cookie.setCookieMaxAge = Just (fromIntegral (60 * 60 * 24 * 90)) }
SessionCookie SetCookie |
newtype DBPoolIdleTime Source #
How long db connection are kept alive inside the connecton pool when they're idle
newtype DBPoolMaxConnections Source #
Max number of db connections the connection pool can open to the database
newtype DatabaseUrl Source #
type ConfigBuilder = StateT TMap IO () Source #
newtype ExceptionTracker Source #
Interface for exception tracking services such as sentry
ExceptionTracker | |
|
newtype IdeBaseUrl Source #
Typically "http://localhost:8001", Url where the IDE is running
newtype RLSAuthenticatedRole Source #
Postgres role to be used for making queries with Row level security enabled
newtype AssetVersion Source #
newtype CustomMiddleware Source #
CustomMiddleware Middleware |
newtype Initializer Source #
Initializer | |
|
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!")
data FrameworkConfig Source #
FrameworkConfig | |
|
Instances
HasField "frameworkConfig" ControllerContext FrameworkConfig Source # | |
Defined in IHP.Controller.Context | |
HasField "frameworkConfig" FrameworkConfig FrameworkConfig Source # | |
Defined in IHP.FrameworkConfig |
type ConfigProvider context = HasField "frameworkConfig" context FrameworkConfig Source #
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 #
Instances
Show RootApplication Source # | |
Defined in IHP.FrameworkConfig showsPrec :: Int -> RootApplication -> ShowS # show :: RootApplication -> String showList :: [RootApplication] -> ShowS # | |
Eq RootApplication Source # | |
Defined in IHP.FrameworkConfig (==) :: 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
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
defaultCorsResourcePolicy :: Maybe CorsResourcePolicy Source #
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
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
Instances
Exception ExceptionWithCallStack Source # | |
Show ExceptionWithCallStack Source # | |
Defined in IHP.FrameworkConfig showsPrec :: Int -> ExceptionWithCallStack -> ShowS # show :: ExceptionWithCallStack -> String showList :: [ExceptionWithCallStack] -> ShowS # |
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.
Orphan instances
EnvVarReader IPAddrSource Source # | |
envStringToValue :: ByteString -> Either Text IPAddrSource Source # |