[basic request handling
thomashartman1@gmail.com**20080620013632] hunk ./src/Controller.hs 14
-
+import ControllerBasic
hunk ./src/Controller.hs 20
- tutorial ++ loginHandlers ++ miscHandlers ++ staticfiles
+ tutorial ++ loginHandlers ++ simpleHandlers ++ staticfiles
hunk ./src/Controller.hs 31
-miscHandlers = [
- exactdir "testtgio" favoriteAnimal
- , (exactdir "home" home )
- , (exactdir "home/1" home1 )
- , (exactdir "ioaction" helloworldio)
- , dir "dirdemo" [ msgToSp "dir match. subpages will work" ]
- , exactdir "exactdirdemo" [ msgToSp "Your request matched the exactdir request handler" ]
-
- -- fileserve handles all possible requests, not that this is necessarily a good thing
- -- , msgToSp "Sorry, we can't find that page."
- ]
+-- serve arbitrary io actions: read files, fetch from database
+helloworldio = [ ioMsgToSp iovalue ]
+ where iovalue :: IO HtmlString
+ iovalue = (return . HtmlString ) "hello
world"
hunk ./src/Controller.hs 58
-home = [ msgToSp "Welcome to HAppS Tutorial"]
-home1 = [ msgToSp "Welcome to HAppS Tutorial, page 1"]
-
-favoriteAnimal = [withTemplate "myhomepage" f]
- where f = setAttribute "favoriteAnimal" "giraffe"
-
--- serve arbitrary io actions: read files, fetch from database
-helloworldio = [ ioMsgToSp iovalue ]
- where iovalue :: IO HtmlString
- iovalue = (return . HtmlString ) "hello
world"
-
hunk ./templates/basic-url-handling.st 1
-
One of the most basic functions of a web framework is to give you a way of controlling what happens when a web browser makes an http request.
+ +Before explaining the theory of request handling in HAppS, let's look at some simple examples.
+ + + +