1
import Data.ByteString.Char8 (unpack, pack)
1
{-# LANGUAGE OverloadedStrings #-}
3
import Data.ByteString.Char8 (pack)
2
4
import Data.ByteString.Lazy (fromChunks)
6
import Network.HTTP.Types
4
import Network.Wai.Enumerator
5
8
import Network.Wai.Middleware.Gzip
6
9
import Network.Wai.Middleware.Jsonp
7
import Network.Wai.Middleware.CleanPath
8
import Network.Wai.Handler.SimpleServer
10
import Network.Wai.Handler.Warp
10
app :: [String] -> Application
11
app [] _ = return $ Response Status200 [] $ Right $ fromLBS
12
$ fromChunks $ flip map [1..10000] $ \i -> pack $
13
app request = return $ case pathInfo request of
14
[] -> responseLBS status200 []
15
$ fromChunks $ flip map [1..10000] $ \i -> pack $ concat
14
16
[ "<p>Just this same paragraph again. "
18
app ["test.html"] _ = return $ Response Status200 [] $ Left "test.html"
19
app ["json"] _ =return $ Response Status200
20
[(ContentType, pack "application/json")]
22
app _ _ = return $ Response Status404 [] $ Left "../LICENSE"
20
["test.html"] -> ResponseFile status200 [] "test.html" Nothing
21
["json"] -> ResponseFile status200 [(hContentType, "application/json")]
23
_ -> ResponseFile status404 [] "../LICENSE" Nothing
25
main = run 3000 $ jsonp $ gzip $ cleanPath app
26
main = run 3000 $ gzip def $ jsonp app