snap-server-0.9.5.1: A fast, iteratee-based, epoll-enabled web server for the Snap Framework

Safe HaskellNone
LanguageHaskell98

Snap.Http.Server.Config

Description

This module exports the Config datatype, which you can use to configure the Snap HTTP server.

Synopsis

Documentation

data 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:

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.

Instances

Show (Config m a) 
Monoid (Config m a) 
Typeable ((* -> *) -> * -> *) Config 

data ConfigLog Source

Data type representing the configuration of a logging target

Constructors

ConfigNoLog

no logging

ConfigFileLog FilePath

log to text file

ConfigIoLog (ByteString -> IO ())

log custom IO handler

Instances

emptyConfig :: Config m a Source

Returns a completely empty Config. Equivalent to mempty from Config's Monoid instance.

defaultConfig :: MonadSnap m => Config m a Source

These are the default values for the options

commandLineConfig Source

Arguments

:: MonadSnap m 
=> Config m a

default configuration. This is combined with defaultConfig to obtain default values to use if the given parameter is specified on the command line. Usually it is fine to use emptyConfig here.

-> IO (Config m a) 

Returns a Config obtained from parsing command-line options, using the default Snap OptDescr set.

On Unix systems, the locale is read from the LANG environment variable.

extendedCommandLineConfig Source

Arguments

:: MonadSnap m 
=> [OptDescr (Maybe (Config m a))]

User options.

-> (a -> a -> a)

State for multiple invoked user command-line options will be combined using this function.

-> Config m a

default configuration. This is combined with Snap's defaultConfig to obtain default values to use if the given parameter is specified on the command line. Usually it is fine to use emptyConfig here.

-> IO (Config m a) 

Returns a Config obtained from parsing command-line options, using the default Snap OptDescr set as well as a list of user OptDescrs. User OptDescrs use the "other" field (accessible using getOther and setOther) to store additional command-line option state. These are combined using a user-defined combining function.

On Unix systems, the locale is read from the LANG environment variable.

optDescrs Source

Arguments

:: MonadSnap m 
=> Config m a

the configuration defaults.

-> [OptDescr (Maybe (Config m a))] 

Returns a description of the snap command line options suitable for use with System.Console.GetOpt.

fmapOpt :: (a -> b) -> OptDescr a -> OptDescr b Source

getAccessLog :: Config m a -> Maybe ConfigLog Source

Path to the access log

getBind :: Config m a -> Maybe ByteString Source

Returns the address to bind to (for http)

getCompression :: Config m a -> Maybe Bool Source

If set and set to True, compression is turned on when applicable

getErrorHandler :: Config m a -> Maybe (SomeException -> m ()) Source

A MonadSnap action to handle 500 errors

getErrorLog :: Config m a -> Maybe ConfigLog Source

Path to the error log

getHostname :: Config m a -> Maybe ByteString Source

The hostname of the HTTP server. This field has the same format as an HTTP Host header; if a Host header came in with the request, we use that, otherwise we default to this value specified in the configuration.

getLocale :: Config m a -> Maybe String Source

Gets the locale to use. Locales are used on Unix only, to set the LANG/LC_ALL/etc. environment variable. For instance if you set the locale to "en_US", we'll set the relevant environment variables to "en_US.UTF-8".

getPort :: Config m a -> Maybe Int Source

Returns the port to listen on (for http)

getSSLBind :: Config m a -> Maybe ByteString Source

Returns the address to bind to (for https)

getSSLCert :: Config m a -> Maybe FilePath Source

Path to the SSL certificate file

getSSLKey :: Config m a -> Maybe FilePath Source

Path to the SSL key file

getSSLChainCert :: Config m a -> Maybe Bool Source

Path to the SSL certificate file

getSSLPort :: Config m a -> Maybe Int Source

Returns the port to listen on (for https)

getVerbose :: Config m a -> Maybe Bool Source

Whether to write server status updates to stderr

getStartupHook :: Config m a -> Maybe (StartupInfo m a -> IO ()) Source

A startup hook is run after the server initializes but before user request processing begins. The server passes, through a StartupInfo object, the startup hook a list of the sockets it is listening on and the final Config object completed after command-line processing.

setErrorHandler :: (SomeException -> m ()) -> Config m a -> Config m a Source

setOther :: a -> Config m a -> Config m a Source

setPort :: Int -> Config m a -> Config m a Source

setSSLPort :: Int -> Config m a -> Config m a Source

setStartupHook :: (StartupInfo m a -> IO ()) -> Config m a -> Config m a Source

data StartupInfo m a Source

Arguments passed to setStartupHook.

getStartupSockets :: StartupInfo m a -> [Socket] Source

The the Sockets opened by the server. There will be two Sockets for SSL connections, and one otherwise.