on a9df06e help sign in
typeable/wai/test/sample.hs
25 lines 950 B history raw
1import Data.ByteString.Char8 (unpack, pack)
2import Data.ByteString.Lazy (fromChunks)
3import Network.Wai
4import Network.Wai.Enumerator
5import Network.Wai.Middleware.Gzip
6import Network.Wai.Middleware.Jsonp
7import Network.Wai.Middleware.CleanPath
8import Network.Wai.Handler.SimpleServer
10app :: [String] -> Application
11app [] _ = return $ Response Status200 [] $ Right $ fromLBS
12 $ fromChunks $ flip map [1..10000] $ \i -> pack $
13 concat
14 [ "<p>Just this same paragraph again. "
15 , show i
16 , "</p>"
17 ]
18app ["test.html"] _ = return $ Response Status200 [] $ Left "test.html"
19app ["json"] _ =return $ Response Status200
20 [(ContentType, pack "application/json")]
21 $ Left "json"
22app _ _ = return $ Response Status404 [] $ Left "../LICENSE"
24main :: IO ()
25main = run 3000 $ jsonp $ gzip $ cleanPath app