web-mongrel2 0.0.2.1 → 0.0.2.2
raw patch · 3 files changed
+31/−6 lines, 3 files
Files
- src/Web/Mongrel2.hs +3/−0
- src/Web/Mongrel2/Types.hs +27/−5
- web-mongrel2.cabal +1/−1
src/Web/Mongrel2.hs view
@@ -12,6 +12,8 @@ -- A simple abstraction for applications to use Mongrel2. -- Mongrel2 is simple and easy to use, and hopefully others -- find this module almost as easy.+-- +-- Please direct any questions or comments, and /especially/ criticism to my email. This is my first release to hackage and I'm very interested in how I can improve. -- -- > require Web.Mongrel2 -- > require Control.Monad (forever)@@ -94,6 +96,7 @@ recv :: (Request -> IO Response) -> M2 -> [Z.Poll] -> IO () recv handle pub ((Z.S s _):_ss) = do req <- Z.receive s []+ putStrLn $ "REQ:\n" ++ (show req) case m2_parse (BS.unpack req) of Left err -> error err Right rq -> do
src/Web/Mongrel2/Types.hs view
@@ -6,10 +6,14 @@ -- | An incoming request from the server. data Request = Request {+ -- | The uuid of the server. request_uuid :: String,+ -- | The path as passed in from Mongrel2. request_path :: String,+ -- | The individual request id. request_id :: String, + -- | Any headers passed in from the server are copied to here. request_headers :: [(String,String)], request_method :: String, request_version :: String,@@ -22,23 +26,42 @@ } deriving (Show) -- | The response to send back.+-- 'response_uuid', 'response_id', and 'response_path' are passed from the request and are needed for the response back to Mongrel2. data Response = Response {+ -- | The uuid of the server. response_uuid :: String,+ -- | The request id. response_id :: String,+ -- | The request path. response_path :: String, - response_body :: String,+ -- | This is for, for example, cookies.+ -- + -- > def { + -- > response_headers = [("cookies","uid=10239120192")]+ -- > }+ -- + -- Of course, they will need to be encoded, etc.+ -- May I be so bold as to suggest @Web.Encodings@ ? :) + -- response_headers :: [(String,String)],+ + -- | 404, 302, etc. response_status :: String,+ -- | Defaults to UTF-8 response_charset :: String,+ -- | Defaults to text/plain response_content_type :: String,- response_target :: Maybe String+ response_body :: String } deriving(Show) --- | Internal connection data.+-- | Internal connection data. +-- 'm2_publish' and 'm2_pull' can be any ZeroMQ type that Mongrel2 supports. data M2 = M2 {+ -- | The address to connect for replies back to Mongrel2. m2_publish :: String, m2_publish_socket :: Maybe (Socket Pub),+ -- | The address to poll for requests. m2_pull :: String, m2_pull_socket :: Maybe (Socket Pull), m2_context :: Maybe Context,@@ -80,8 +103,7 @@ response_charset = "UTF-8", response_content_type = "text/plain",- response_body = def, response_headers = def, response_status = def,- response_target = Nothing+ response_body = def }
web-mongrel2.cabal view
@@ -1,5 +1,5 @@ name: web-mongrel2-version: 0.0.2.1+version: 0.0.2.2 build-type: Simple license: BSD3 license-file: LICENSE