module Main where

import Control.Applicative ((<$>), (<*>))
import Happstack.Server (ServerPart, badRequest, nullConf, ok, simpleHTTP)
import Happstack.Server.RqData (RqData, lookRead, getDataFn)

lookInt :: RqData Int
lookInt = lookRead "int"

intPart :: ServerPart String
intPart =
    do r <- getDataFn lookInt
       case r of
         (Left e) ->
             badRequest $ unlines e
         (Right i) ->
             ok $ "Read the int: " ++ show i

main :: IO ()
main = simpleHTTP nullConf $ intPart
