mongrel2-handler-0.3.1: Mongrel2 Handler Library




mkHandler :: String -> String -> Maybe String -> HandlerSource

Create a new handler. mkHandler pullFromAddress publishToAddress id creates a handler which pulls requests from fromAddress and publishes replies to publishAddress.

withConnectedHandler :: Handler -> (ConnectedHandler -> IO a) -> IO aSource

Run an IO action with a connected handler.

receiveRequest :: ConnectedHandler -> IO (Connection, Request)Source

Receive a parsed request from the Mongrel2 server. Blocks until a message is received. The Mongrel2 server will signal a client disconnect by sending a Request with method JSON and a request body containing a JSON object with a key type containing the value disconnect. No response should be sent for such a request.

sendReply :: ConnectedHandler -> UUID -> [ClientID] -> Builder -> IO ()Source

Send a reply to the Mongrel2 server.

buildResponse :: Status -> ResponseHeaders -> ByteString -> BuilderSource

Build a HTTP response.

type ClientID = Int64Source

Client identifier from Mongrel2. This identifies the currently connected client uniquely.

data Connection Source

Connection information.




connServerUUID :: UUID

UUID of the connected Mongrel2 server.

connClientID :: ClientID

ID of the connected client browser.


data Request Source

Request information.




reqPath :: [Text]

Request path

reqQuery :: Query

Query part of the request

reqRawPath :: ByteString

Raw request path including query part.

reqMethod :: Either Ascii StdMethod

Request method (GET, POST, etc.)

reqVersion :: Maybe HttpVersion

HTTP version

reqHeaders :: RequestHeaders

Request headers

reqBody :: ByteString

Request body.


type UUID = ByteStringSource

UUID for communicating with Mongrel2.