snap-0.5.2: 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

- type ConfigExtend s = Config (SnapExtend s) (IO [(ByteString, Maybe ByteString)] -> SnapExtend s ())
- httpServe :: ConfigExtend s -> Initializer s -> SnapExtend s () -> IO ()
- quickHttpServe :: Initializer s -> SnapExtend s () -> IO ()
- defaultConfig :: ConfigExtend s
- getReloadHandler :: ConfigExtend s -> Maybe (IO [(ByteString, Maybe ByteString)] -> SnapExtend s ())
- setReloadHandler :: (IO [(ByteString, Maybe ByteString)] -> SnapExtend s ()) -> ConfigExtend s -> ConfigExtend s
- module Snap.Http.Server.Config

# Documentation

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

`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`.

httpServe

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.

quickHttpServe

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 s

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)

getReloadHandler :: ConfigExtend s -> Maybe (IO [(ByteString, Maybe ByteString)] -> SnapExtend s ())

setReloadHandler :: (IO [(ByteString, Maybe ByteString)] -> SnapExtend s ()) -> ConfigExtend s -> ConfigExtend s

module Snap.Http.Server.Config