- data MonadSnap m => Config m a
- data ConfigListen
- data ConfigBackend
- emptyConfig :: MonadSnap m => Config m a
- defaultConfig :: MonadSnap m => Config m a
- completeConfig :: MonadSnap m => Config m a -> Config m a
- commandLineConfig :: MonadSnap m => Config m a -> IO (Config m a)
- getHostname :: MonadSnap m => Config m a -> Maybe ByteString
- getListen :: MonadSnap m => Config m a -> [ConfigListen]
- getAccessLog :: MonadSnap m => Config m a -> Maybe (Maybe FilePath)
- getErrorLog :: MonadSnap m => Config m a -> Maybe (Maybe FilePath)
- getLocale :: MonadSnap m => Config m a -> Maybe String
- getBackend :: MonadSnap m => Config m a -> Maybe ConfigBackend
- getCompression :: MonadSnap m => Config m a -> Maybe Bool
- getVerbose :: MonadSnap m => Config m a -> Maybe Bool
- getErrorHandler :: MonadSnap m => Config m a -> Maybe (SomeException -> m ())
- getDefaultTimeout :: MonadSnap m => Config m a -> Maybe Int
- getOther :: MonadSnap m => Config m a -> Maybe a
- setHostname :: MonadSnap m => ByteString -> Config m a -> Config m a
- addListen :: MonadSnap m => ConfigListen -> Config m a -> Config m a
- setAccessLog :: MonadSnap m => Maybe FilePath -> Config m a -> Config m a
- setErrorLog :: MonadSnap m => Maybe FilePath -> Config m a -> Config m a
- setLocale :: MonadSnap m => String -> Config m a -> Config m a
- setBackend :: MonadSnap m => ConfigBackend -> Config m a -> Config m a
- setCompression :: MonadSnap m => Bool -> Config m a -> Config m a
- setVerbose :: MonadSnap m => Bool -> Config m a -> Config m a
- setErrorHandler :: MonadSnap m => (SomeException -> m ()) -> Config m a -> Config m a
- setDefaultTimeout :: MonadSnap m => Int -> Config m a -> Config m a
- setOther :: MonadSnap m => a -> Config m a -> Config m a
Documentation
data MonadSnap m => Config m a Source
A record type which represents partial configurations (for httpServe
)
by wrapping all of its fields in a Maybe
. Values of this type are usually
constructed via its Monoid
instance by doing something like:
addListen (ListenHttp "0.0.0.0" 9000) mempty
Any fields which are unspecified in the Config
passed to httpServe
(and
this is the norm) are filled in with default values from defaultConfig
.
data ConfigListen Source
A data type to store the bind address and port to listen on.
For SSL support, it also stores the path to the certificate in PEM format and the path to the private key in PEM format
data ConfigBackend Source
A data type to record which backend event loop should be used when serving data.
emptyConfig :: MonadSnap m => Config m aSource
defaultConfig :: MonadSnap m => Config m aSource
These are the default values for all the fields in Config
.
hostname = "localhost" listen = [] accessLog = "log/access.log" errorLog = "log/error.log" locale = "en_US" backend = Nothing (the backend is selected based on compile options) compression = True verbose = True errorHandler = prints the error message
completeConfig :: MonadSnap m => Config m a -> Config m aSource
Completes a partial Config
by filling in the unspecified values with
the default values from defaultConfig
. Also, if no listeners are
specified, adds a http listener on 0.0.0.0:8000
commandLineConfig :: MonadSnap m => Config m a -> IO (Config m a)Source
This returns a Config
gotten from parsing the options specified on the
command-line.
The Config
parameter is just for specifying any default values which are
to override those in defaultConfig
. This is so the usage message can
accurately inform the user what the default values for the options are. In
most cases, you will probably just end up passing mempty
for this
parameter.
On Unix systems, the locale is read from the LANG
environment variable.
getHostname :: MonadSnap m => Config m a -> Maybe ByteStringSource
getListen :: MonadSnap m => Config m a -> [ConfigListen]Source
getBackend :: MonadSnap m => Config m a -> Maybe ConfigBackendSource
getErrorHandler :: MonadSnap m => Config m a -> Maybe (SomeException -> m ())Source
setHostname :: MonadSnap m => ByteString -> Config m a -> Config m aSource
setBackend :: MonadSnap m => ConfigBackend -> Config m a -> Config m aSource
setErrorHandler :: MonadSnap m => (SomeException -> m ()) -> Config m a -> Config m aSource