Created
March 12, 2012 18:44
-
-
Save kowey/2023894 to your computer and use it in GitHub Desktop.
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Exception | |
import Control.Monad ( liftM, ap ) | |
import Control.Monad.IO.Class | |
import Data.Conduit | |
import Data.Conduit.Lazy | |
import Data.IORef | |
import Network.HTTP.Types (statusOK, status400, Header, Ascii) | |
import Network.Wai | |
import Network.Wai.Handler.Warp -- (run) | |
import System.IO | |
import qualified Data.ByteString.Lazy as B | |
import qualified Network.Wai.Middleware.RequestLogger as W | |
main = do | |
hPutStrLn stderr $ "Listening on port " ++ show (settingsPort settings) | |
runSettings settings (W.logStdout application) | |
where | |
settings = defaultSettings { settingsHost = "127.0.0.1" -- force IPv4 usage | |
, settingsPort = 4000 | |
} | |
application :: Application | |
application req = liftIO $ do | |
bss <- runResourceT . lazyConsume . requestBody $ req | |
B.putStrLn (B.fromChunks bss) | |
return $ responseLBS statusOK [("Content-type","text/plain")] $ B.fromChunks bss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment