Snap.Http.Server.Config
Description
This module exports the Config datatype, which you can use to configure the
Snap HTTP server.
- data Config m a
- data ConfigBackend
- emptyConfig :: Config m a
- defaultConfig :: MonadSnap m => Config m a
- commandLineConfig :: MonadSnap m => Config m a -> IO (Config m a)
- completeConfig :: MonadSnap m => Config m a -> IO (Config m a)
- getAccessLog :: Config m a -> Maybe (Maybe FilePath)
- getBackend :: Config m a -> Maybe ConfigBackend
- getBind :: Config m a -> Maybe ByteString
- getCompression :: Config m a -> Maybe Bool
- getDefaultTimeout :: Config m a -> Maybe Int
- getErrorHandler :: Config m a -> Maybe (SomeException -> m ())
- getErrorLog :: Config m a -> Maybe (Maybe FilePath)
- getHostname :: Config m a -> Maybe ByteString
- getLocale :: Config m a -> Maybe String
- getOther :: Config m a -> Maybe a
- getPort :: Config m a -> Maybe Int
- getSSLBind :: Config m a -> Maybe ByteString
- getSSLCert :: Config m a -> Maybe FilePath
- getSSLKey :: Config m a -> Maybe FilePath
- getSSLPort :: Config m a -> Maybe Int
- getVerbose :: Config m a -> Maybe Bool
- setAccessLog :: Maybe FilePath -> Config m a -> Config m a
- setBackend :: ConfigBackend -> Config m a -> Config m a
- setBind :: ByteString -> Config m a -> Config m a
- setCompression :: Bool -> Config m a -> Config m a
- setDefaultTimeout :: Int -> Config m a -> Config m a
- setErrorHandler :: (SomeException -> m ()) -> Config m a -> Config m a
- setErrorLog :: Maybe FilePath -> Config m a -> Config m a
- setHostname :: ByteString -> Config m a -> Config m a
- setLocale :: String -> Config m a -> Config m a
- setOther :: a -> Config m a -> Config m a
- setPort :: Int -> Config m a -> Config m a
- setSSLBind :: ByteString -> Config m a -> Config m a
- setSSLCert :: FilePath -> Config m a -> Config m a
- setSSLKey :: FilePath -> Config m a -> Config m a
- setSSLPort :: Int -> Config m a -> Config m a
- setVerbose :: Bool -> Config m a -> Config m a
Documentation
data Config m a
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:
setPort 1234 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 ConfigBackend
This datatype allows you to override which backend (either simple or libev) to use. Most users will not want to set this, preferring to rely on the compile-type default.
Note that if you specify the libev backend and have not compiled in support for it, your server will fail at runtime.
Constructors
| ConfigSimpleBackend | |
| ConfigLibEvBackend |
Instances
emptyConfig :: Config m a
defaultConfig :: MonadSnap m => Config m a
These are the default values for the options
Arguments
| :: MonadSnap m | |
| => Config m a | default configuration. This is combined
with |
| -> IO (Config m a) |
Returns a Config obtained from parsing the options specified on the
command-line.
On Unix systems, the locale is read from the LANG environment variable.
completeConfig :: MonadSnap m => Config m a -> IO (Config m a)
getAccessLog :: Config m a -> Maybe (Maybe FilePath)
Path to the access log
getBackend :: Config m a -> Maybe ConfigBackend
getBind :: Config m a -> Maybe ByteString
Returns the address to bind to (for http)
getCompression :: Config m a -> Maybe Bool
If set and set to True, compression is turned on when applicable
getDefaultTimeout :: Config m a -> Maybe Int
getErrorHandler :: Config m a -> Maybe (SomeException -> m ())
A MonadSnap action to handle 500 errors
getErrorLog :: Config m a -> Maybe (Maybe FilePath)
Path to the error log
getHostname :: Config m a -> Maybe ByteString
The hostname of the HTTP server
getSSLBind :: Config m a -> Maybe ByteString
Returns the address to bind to (for https)
getSSLCert :: Config m a -> Maybe FilePath
Path to the SSL certificate file
getSSLPort :: Config m a -> Maybe Int
Returns the port to listen on (for https)
getVerbose :: Config m a -> Maybe Bool
Whether to write server status updates to stderr
setAccessLog :: Maybe FilePath -> Config m a -> Config m a
setBackend :: ConfigBackend -> Config m a -> Config m a
setBind :: ByteString -> Config m a -> Config m a
setCompression :: Bool -> Config m a -> Config m a
setDefaultTimeout :: Int -> Config m a -> Config m a
setErrorHandler :: (SomeException -> m ()) -> Config m a -> Config m a
setErrorLog :: Maybe FilePath -> Config m a -> Config m a
setHostname :: ByteString -> Config m a -> Config m a
setSSLBind :: ByteString -> Config m a -> Config m a
setSSLCert :: FilePath -> Config m a -> Config m a
setSSLPort :: Int -> Config m a -> Config m a
setVerbose :: Bool -> Config m a -> Config m a