view App.hs @ 2:4f374ebe6b99

fix
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 02 Jul 2013 18:31:35 +0900
parents 616d3e6ce483
children 1363ce4186a7
line wrap: on
line source

{-# LANGUAGE OverloadedStrings #-}

import Types
import Routes
import Network.Wai (Request, Response, pathInfo, queryString)
import Network.Wai.Parse (parseRequestBody, lbsBackEnd)
import Network.Wai.Handler.Warp (run)
import Control.Monad.Trans (lift, liftIO)
import Data.Conduit (ResourceT)
import Control.Concurrent.STM
import qualified Jungle as J

application :: TJungle -> Request -> ResourceT IO Response
application jungle request = do
    let
      function = routes $ pathInfo request
      query    = queryString request
    (params, _) <- parseRequestBody lbsBackEnd request
    liftIO $ print params
    lift $ function jungle query params

main = do 
    putStrLn $ "Listening on port " ++ show 3000
    jungle <- newJungle
    run 3000 $ application jungle