Some docs

portnov [2009-07-07 16:11:30]
Some docs
Filename
Framework/API.hs
Framework/Logger.hs
Framework/Urls.hs
diff --git a/Framework/API.hs b/Framework/API.hs
index 3fc3602..c117d4a 100644
--- a/Framework/API.hs
+++ b/Framework/API.hs
@@ -103,8 +103,15 @@ setcookie ac name value = Cookies.setcookie (cookiesExp ac) name value
 ----------------------------------------------------------------------------------------------------------
 -- * Logger API

-accessLog :: ActionConfig -> String -> IO ()
+-- | Write a message to access log
+accessLog :: ActionConfig
+          -> String        -- ^ Log message
+          -> IO ()
 accessLog ac msg = Logger.writeLog (logChan $ httpParams ac) (request ac) msg

-errorLog :: ActionConfig -> String -> IO ()
+-- | Write a message to errors log
+errorLog :: ActionConfig
+         -> String         -- ^ Log message
+         -> IO ()
 errorLog ac msg = Logger.writeLog (errChan $ httpParams ac) (request ac) msg
+
diff --git a/Framework/Logger.hs b/Framework/Logger.hs
index 05c39b6..cfe25a9 100644
--- a/Framework/Logger.hs
+++ b/Framework/Logger.hs
@@ -1,7 +1,6 @@
 {-# LANGUAGE TypeSynonymInstances #-}
 module Framework.Logger
-    (Log,
-     writeLog,
+    (writeLog,
      runLogWriter
     ) where

@@ -27,12 +26,21 @@ currentTime = do
 formatMsg ::  LogItem -> String
 formatMsg item = printf "%s: %s" (logTime item) (logMessage item)

-writeLog :: Log -> HttpRequest -> String -> IO ()
+-- | Write a message to log
+writeLog :: Log            -- ^ Log channel
+         -> HttpRequest    -- ^ HTTP request
+         -> String         -- ^ Log message
+         -> IO ()
 writeLog chan rq msg = do
     time <- currentTime
     writeChan chan $ LogItem rq time msg

-runLogWriter :: Log -> Log -> Handle -> Handle -> IO ThreadId
+-- | Run log-writer threads
+runLogWriter :: Log          -- ^ Log channel for access log
+             -> Log          -- ^ Log channel for errors log
+             -> Handle       -- ^ Handle to opened access log
+             -> Handle       -- ^ Handle to opened errors log
+             -> IO ThreadId
 runLogWriter aLog eLog afile efile = do
     forkIO $ flushLog eLog efile
     forkIO $ flushLog aLog afile
diff --git a/Framework/Urls.hs b/Framework/Urls.hs
index 5dc822a..73fef6d 100644
--- a/Framework/Urls.hs
+++ b/Framework/Urls.hs
@@ -1,6 +1,17 @@
 {-# LANGUAGE NamedFieldPuns #-}
 -- | URL dispatcher
-module Framework.Urls where
+module Framework.Urls
+    (URLConf (..),
+     runURLConf,
+     StrAction, StaticAction,
+     ManyStrAction, HttpAction,
+     (-->), (//), (-\>), (~>),
+     (~/), (~>>), (<|>),
+     httpGetVar, httpGetVar',
+     httpPostVar, httpPostVar',
+     httpAddGetVar,
+     myUrl
+    ) where

 import Debug.Trace

@@ -132,24 +143,28 @@ s --> act = Prefix s (Action act)
 (//) = Prefix
 infixr 7 //

+-- | If current part of URL matches given string, then run function
 (-\>) :: String -> StrAction -> URLConf
 s -\> f = s // Function f

+-- | Same as "RegexpFun"
 (~>) :: String -> StrAction -> URLConf
 (~>) = RegexpFun
 infixl 8 ~>

+-- | Forms "ManyRegexpFun"
 (~/) :: String -> URLConf -> URLConf
 r ~/ c =  case c of
             ManyRegexpFun u rs f -> ManyRegexpFun u (r:rs) f
             _                    -> error "~>> works only with ManyRegexpFun at right side!"
 infixr 8 ~/

+-- | Ends form "ManyRegexpFun"
 (~>>) :: String -> ManyStrAction -> URLConf
 r ~>> f = r ~/ mrf f
+    where mrf f = ManyRegexpFun [] [] f

-mrf f = ManyRegexpFun [] [] f
-
+-- | Same as "OneOf"
 (<|>) :: URLConf -> URLConf -> URLConf
 (<|>) = OneOf
 infixr 6 <|>
ViewGit