on master help sign in
Merge pull request #261 from sol/master

wai: Update README

commit4c29ebbfd1b0b82dc887c6f13bf5943f7d1f4803 authorMichael Snoyman <michael@snoyman.com> dateTue 10 Jun 2014, 07:22 (12 years ago) parent91506f01354086
2 files changed+11−20
wai/README.md+11−11 wai/test.hs−9
wai/README.md+11−11
@@ -13,12 +13,12 @@ import Network.HTTP.Types
1313import Network.Wai.Handler.Warp (run)
1414
1515app :: Application
16−app _ = do
17− putStrLn "I've done some IO here"
18− return $ responseLBS
19− status200
20− [("Content-Type", "text/plain")]
21− "Hello, Web!"
16+app _ respond = do
17+ putStrLn "I've done some IO here"
18+ respond $ responseLBS
19+ status200
20+ [("Content-Type", "text/plain")]
21+ "Hello, Web!"
2222
2323main :: IO ()
2424main = do
@@ -50,7 +50,7 @@ Now we redefine `responseBody` to refer to that file:
5050
5151~~~ {.haskell}
5252app2 :: Application
53−app2 _ = return index
53+app2 _ respond = respond index
5454
5555index :: Response
5656index = responseFile
@@ -73,10 +73,10 @@ Depending on the path info provided with each `Request` we can serve different `
7373
7474~~~ {.haskell}
7575app3 :: Application
76−app3 request = case rawPathInfo request of
77− "/" -> return index
78− "/raw/" -> return plainIndex
79− _ -> return notFound
76+app3 request respond = respond $ case rawPathInfo request of
77+ "/" -> index
78+ "/raw/" -> plainIndex
79+ _ -> notFound
8080
8181plainIndex :: Response
8282plainIndex = responseFile
wai/test.hsdeleted−9
@@ -1,9 +0,0 @@
1−import Network.Wai
2−import Data.Enumerator.List (consume)
3−import Blaze.ByteString.Builder (toByteString)
4−import Data.Monoid (mconcat)
5−import Data.ByteString.Char8 (pack)
6−
7−main = do
8− b <- responseEnumerator (ResponseFile undefined undefined "test.hs" (Just $ FilePart 7 7)) (const $ const consume)
9− print $ toByteString (mconcat b) == pack "Network"