[documentation updates jeremy@n-heptane.com**20111115001205 Ignore-this: e1eb0a47d55a650b9814c3df03f0d26a ] hunk ./bin/haddock-all.sh 12 -## required hunk ./bin/haddock-all.sh 34 - cabal configure --builddir $DESTDIR && cabal haddock --builddir $DESTDIR --hyperlink-source --internal --html-location="$HTML_LOCATION\$pkg" + cabal configure --builddir $DESTDIR && cabal haddock --builddir $DESTDIR --hyperlink-source --internal --html-location="$HTML_LOCATION\$pkg" --haddock-options="$HADDOCKS" + HADDOCKS="$HADDOCKS -i$DESTDIR/doc/html/$package/$package.haddock" hunk ./happstack-lite/Examples.lhs 9 -light, with out forcing you to give up any of the power and flexible. +light, without forcing you to give up any of the power and flexible. hunk ./happstack-lite/Examples.lhs 14 -a web application into a single module (Happstack.Lite) so you don't +a web application into a single module `Happstack.Lite` so you don't hunk ./happstack-lite/Examples.lhs 40 -The latest HTML-ized version is located at: +http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-lite/Examples.lhs hunk ./happstack-lite/Examples.lhs 42 +The latest HTML-ized version of this document is located at: + +The Haddock documentation for happstack-lite is located at: + +http://happstack.com/docs/6.0.0/happstack-lite/index.html + +For more in-depth information, you can also refer to the Happstack Crash Course at: + +http://www.happstack.com/docs/crashcourse/index.html hunk ./happstack-lite/Examples.lhs 95 -

Static Routing

Static Routing hunk ./happstack-lite/Examples.lhs 124 -http://jaspervdj.be/blaze/tutorial.html +http://jaspervdj.be/blaze/tutorial.html hunk ./happstack-lite/Examples.lhs 153 -'ok' tells the server to return the page with the HTTP response code '200 OK'. There are other helper functions like 'notFound' and 'seeOther' for other response codes. Or use 'setResponseCode' to specify a response code by number. +`ok` tells the server to return the page with the HTTP response code '200 OK'. There are other helper functions like `notFound` and `seeOther` for other response codes. Or use `setResponseCode` to specify a response code by number. hunk ./happstack-lite/Examples.lhs 157 -The 'dir' function only matches on static path segments. If we have a dynamic path segment, we can use the 'path' function to capture the value and optionally convert it to another type such as Integer. In this example we just echo the captured path segment in the html. For example, trying visiting: +The `dir` function only matches on static path segments. If we have a dynamic path segment, we can use the `path` function to capture the value and optionally convert it to another type such as Integer. In this example we just echo the captured path segment in the html. For example, trying visiting: hunk ./happstack-lite/Examples.lhs 159 -http://localhost:8000/echo/fantastic +http://localhost:8000/echo/fantastic hunk ./happstack-lite/Examples.lhs 173 -http://localhost:8000/query?foo=bar +http://localhost:8000/query?foo=bar hunk ./happstack-lite/Happstack/Lite.hs 54 - , msum + , MonadPlus(..) hunk ./happstack-lite/Happstack/Lite.hs 57 -import Control.Monad (MonadPlus, msum) +import Control.Monad (MonadPlus(..)) hunk ./happstack-lite/Happstack/Lite.hs 63 -import Happstack.Server (ContentType, Request, Response, ServerPart, FromReqURI, Method(..), MatchMethod, ToMessage(..), Cookie(..), CookieLife(..), Browsing, mkCookie, toResponseBS) +import Happstack.Server (ContentType, Request, Response, ServerPart, FromReqURI, Method(..), MatchMethod, ToMessage(..), Cookie(..), CookieLife(..), Browsing, mkCookie) hunk ./happstack-lite/Happstack/Lite.hs 92 -serve :: Maybe ServerConfig -> ServerPart Response -> IO () +-- | start the server and handle requests using the supplied 'ServerPart' +serve :: Maybe ServerConfig -- ^ if Nothing, then use 'defaultServerConfig' + -> ServerPart Response -- ^ request handler + -> IO () hunk ./happstack-lite/Happstack/Lite.hs 148 +-- | A low-level function to build a 'Response' from a content-type +-- and a 'ByteString'. +-- +-- Creates a 'Response' in a manner similar to the 'ToMessage' class, +-- but without requiring an instance declaration. +-- +-- example: +-- +-- > import Data.ByteString.Char8 as C +-- > import Data.ByteString.Lazy.Char8 as L +-- > import Happstack.Lite +-- > +-- > main = serve Nothing $ ok $ toResponseBS (C.pack "text/plain") (L.pack "hello, world") +-- +-- (note: 'C.pack' and 'L.pack' only work for ascii. For unicode strings you would need to use @utf8-string@, @text@, or something similar to create a valid 'ByteString'). +toResponseBS :: B.ByteString -- ^ content-type + -> ByteString -- ^ response body + -> Response +toResponseBS = S.toResponseBS + addfile ./happstack-lite/Makefile hunk ./happstack-lite/Makefile 1 +# This Makefile is only used to update the Examples.html file. use cabal to build and install the library + +happstack-lite.html: Examples.lhs Makefile + echo " $@ + echo " \"http://www.w3.org/TR/html4/strict.dtd\">" >> $@ + echo "happstack-lite tutorial" >> $@ + HsColour -lit -css -partial $< | markdown --html4tags >> $@ + echo "">> $@ + validate $@ hunk ./happstack-server/src/Happstack/Server/Routing.hs 38 --- > methodM GET -- match GET --- > methodM [HEAD, GET] -- match HEAD or GET --- > methodM (not . (==) DELETE) -- match any method except DELETE --- > methodM () -- match any method +-- > method GET -- match GET +-- > method [HEAD, GET] -- match HEAD or GET +-- > method (not . (==) DELETE) -- match any method except DELETE +-- > method () -- match any method hunk ./happstack-server/src/Happstack/Server/SimpleHTTP.hs 182 +-- hunk ./happstack-server/src/Happstack/Server/SimpleHTTP.hs 192 +--