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

Snap.Http.Server.Config

Description

This module exports the Config datatype which represents partially-specified configurations of "serve" functions which run Snap actions in IO.

Synopsis

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.

Instances

MonadSnap m => Show (Config m a) 
MonadSnap m => Monoid (Config m a) 

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

Instances

data ConfigBackend Source

A data type to record which backend event loop should be used when serving data.

emptyConfig :: MonadSnap m => Config m aSource

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

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.

setOther :: MonadSnap m => a -> Config m a -> Config m aSource