snap-0.4.3: Snap: A Haskell Web Framework: project starter executable and glue code library

Snap.Extension.Server

Description

This module provides replacements for the httpServe and quickHttpServe functions exported by Snap.Http.Server. By taking a Initializer as an argument, these functions simplify the glue code that is needed to use Snap Extensions.

Synopsis

Documentation

type ConfigExtend s = Config (SnapExtend s) (IO [(ByteString, Maybe ByteString)] -> SnapExtend s ())Source

ConfigExtend is similar to the Config exported by Snap.Http.Server, but is augmented with a reloadHandler field which can be accessed using getReloadHandler and setReloadHandler.

httpServeSource

Arguments

:: ConfigExtend s

Any configuration options which override the defaults

-> Initializer s

The Initializer function for the application's monad

-> SnapExtend s ()

The application to be served

-> IO () 

Starts serving HTTP requests using the given handler, with settings from the ConfigExtend passed in. This function never returns; to shut down the HTTP server, kill the controlling thread.

quickHttpServeSource

Arguments

:: Initializer s

The Initializer function for the application's monad

-> SnapExtend s ()

The application to be served

-> IO () 

Starts serving HTTP using the given handler. The configuration is read from the options given on the command-line, as returned by commandLineConfig.

defaultConfig :: ConfigExtend sSource

These are the default values for all the fields in ConfigExtend.

 hostname      = "localhost"
 address       = "0.0.0.0"
 port          = 8000
 accessLog     = "log/access.log"
 errorLog      = "log/error.log"
 locale        = "en_US"
 compression   = True
 verbose       = True
 errorHandler  = prints the error message
 reloadHandler = prints the result of each reload handler (error/success)