{-# OPTIONS -fcontext-stack=22 -fglasgow-exts -fth #-} import Types import Control import HAppS.Server.State import FaceBlog import Blog import State import qualified Text.XHtml as TXH $(systemState ''State) main = do control <- startSystemState simpleHTTP impl waitForTermination control {-- implementation is just a set of nested ReaderT lists. --} impl = [--style outbound XML with xsltproc --you can use xslt2 with saxon but java startup is still stlow xslt xsltproc "xslt/style.xsl" [--example apps faceblog, -- from module FaceBlog blog, -- example of basic blogging functionality series, -- example of how http paths work now login, -- example of using posted data fileServe ["beforeIndex.html"] "public" -- fileserving ] ] --demonstrate the semantics of dir, method, path series = dir "series" [method GET $ ok "Show all Series" ,path $ \serie -> [method GET $ ok $ "Show specific serie: " ++ serie ,path $ \sid -> [method GET $ ok $ "Show specific season: " ++ show (serie, sid::Int) ] ] ] --demonstrate the semantics of withData -- notice no need to write parsing routine! --we really need Cookie and mailRelay so we can do real authentication here login = dir "login" [ withData $ \(UserInfo (User user) (Pass pass)) -> [method () $ ok $ "UserInfo: " ++ show (user,pass)] -- handles GET and POST -- http://localhost:8000/login?/userInfo/user=alex&/userInfo/pass=mypass -- http://localhost:8000/login?user=alex&pass=mypass ,method GET $ ok "login base" -- executed if no match ]