]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Httpd.hs
docs
[Lucu.git] / Network / HTTP / Lucu / Httpd.hs
index ac1dc77a66379508ac8f1bf2c0528c1f2ddd037a..0d78f986f314f21573aea96c7ff05304c3cea8ba 100644 (file)
@@ -28,26 +28,28 @@ import Prelude.Unicode
 --
 -- Example:
 --
--- > {-# LANGUAGE OverloadedStrings #-}
--- > {-# LANGUAGE QuasiQuotes #-}
--- > module Main where
--- > import Network
--- > import Network.HTTP.Lucu
--- > 
--- > main :: IO ()
--- > main = let config    = defaultConfig
--- >            resources = mkResTree [ ([], helloWorld) ]
--- >        in
--- >          withSocketsDo $ runHttpd config resourcees []
--- >
--- > helloWorld :: Resource
--- > helloWorld = emptyResource {
--- >                resGet
--- >                  = Just $ do setContentType [mimeType| text/plain |]
--- >                              putChunk "Hello, world!"
--- >              }
+-- @
+--   {-\# LANGUAGE OverloadedStrings \#-}
+--   {-\# LANGUAGE QuasiQuotes \#-}
+--   module Main where
+--   import qualified "Data.Collections" as C
+--   import "Network"
+--   import "Network.HTTP.Lucu"
 --
--- FIXME: update the above example
+--   main :: 'IO' ()
+--   main = let config = 'defaultConfig'
+--              tree   :: 'ResourceTree'
+--              tree   = C.fromList [ ([], 'nonGreedy' helloWorld) ]
+--          in
+--            'Network.withSocketsDo' '$' 'runHttpd' config '$' 'resourceMap' tree
+--
+--   helloWorld :: 'Network.HTTP.Lucu.Resource'
+--   helloWorld = C.fromList
+--                [ ( 'Network.HTTP.Lucu.GET'
+--                  , do 'Network.HTTP.Lucu.setContentType' ['Network.HTTP.Lucu.mimeType'| text/plain |]
+--                       'Network.HTTP.Lucu.putChunk' \"Hello, world!\"
+--                }
+-- @
 runHttpd ∷ HostMapper α ⇒ Config → α → IO ()
 runHttpd cnf hm
     = do let launchers