Created
January 18, 2011 19:08
-
-
Save cmoore/784949 to your computer and use it in GitHub Desktop.
web-mongrel2 example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Web.Mongrel2 | |
import Control.Monad (forever) | |
import Text.Groom (groom) | |
import Data.Default (def) | |
main :: IO () | |
main = do | |
let b = def { m2_publish = "tcp://127.0.0.1:9996" | |
, m2_pull = "tcp://127.0.0.1:9997" } | |
bx <- connect b | |
case m2_pull_socket bx of | |
Nothing -> error "Pull socket didn't connect. Is Mongrel2 running?" | |
Just sock -> | |
forever $ poll sock >>= | |
recv dummy bx >> | |
return () | |
where | |
dummy :: Request -> IO Response | |
dummy req = do | |
putStrLn $ groom req | |
return def |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment