[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 -

Basic URL Handling in HAppS

+

Basic Request Handling in HAppS

hunk ./templates/basic-url-handling.st 3 - + hunk ./templates/basic-url-handling.st 16 +
  • A simple request handler
  • +
  • Same idea, using exactdir and msgToSp
  • +
  • exactdirAndmsgToSp/anotherResponse
  • +
  • IO Response +
  • Another IO Response +
  • First attempt at formatted html (wrong)
  • +
  • Second attempt at formatted html (right)
  • +