on master help sign in
Merge pull request #167 from sukhodolin/patches

Fixed a bitrotten sample and a typo in the documentation

commitd264d48430a742c0673b53d1be0bf1652d712a16 authorMichael Snoyman <michael@snoyman.com> dateMon 5 Aug 2013, 08:45 (13 years ago) parent7ed1063bb2a907
2 files changed+17−16
wai-extra/Network/Wai/Middleware/Jsonp.hs+1−1 wai-extra/test/sample.hs+16−15
wai-extra/Network/Wai/Middleware/Jsonp.hs+1−1
@@ -31,7 +31,7 @@ import qualified Data.Conduit.List as CL
3131--
3232-- Basically, if the user requested a \"text\/javascript\" and supplied a
3333-- \"callback\" GET parameter, ask the application for an
34−-- \"application/json\" response, then convern that into a JSONP response,
34+-- \"application/json\" response, then convert that into a JSONP response,
3535-- having a content type of \"text\/javascript\" and calling the specified
3636-- callback function.
3737jsonp :: Middleware
wai-extra/test/sample.hs+16−15
@@ -1,25 +1,26 @@
1−import Data.ByteString.Char8 (unpack, pack)
1+{-# LANGUAGE OverloadedStrings #-}
2+
3+import Data.ByteString.Char8 (pack)
24import Data.ByteString.Lazy (fromChunks)
5+import Data.Text ()
6+import Network.HTTP.Types
37import Network.Wai
4−import Network.Wai.Enumerator
58import Network.Wai.Middleware.Gzip
69import Network.Wai.Middleware.Jsonp
7−import Network.Wai.Middleware.CleanPath
8−import Network.Wai.Handler.SimpleServer
10+import Network.Wai.Handler.Warp
911
10−app :: [String] -> Application
11−app [] _ = return $ Response Status200 [] $ Right $ fromLBS
12− $ fromChunks $ flip map [1..10000] $ \i -> pack $
13− concat
12+app :: Application
13+app request = return $ case pathInfo request of
14+ [] -> responseLBS status200 []
15+ $ fromChunks $ flip map [1..10000] $ \i -> pack $ concat
1416 [ "<p>Just this same paragraph again. "
15− , show i
17+ , show (i :: Int)
1618 , "</p>"
1719 ]
18−app ["test.html"] _ = return $ Response Status200 [] $ Left "test.html"
19−app ["json"] _ =return $ Response Status200
20− [(ContentType, pack "application/json")]
21− $ Left "json"
22−app _ _ = return $ Response Status404 [] $ Left "../LICENSE"
20+ ["test.html"] -> ResponseFile status200 [] "test.html" Nothing
21+ ["json"] -> ResponseFile status200 [(hContentType, "application/json")]
22+ "json" Nothing
23+ _ -> ResponseFile status404 [] "../LICENSE" Nothing
2324
2425main :: IO ()
25−main = run 3000 $ jsonp $ gzip $ cleanPath app
26+main = run 3000 $ gzip def $ jsonp app