Rename: HttpActionParams -> StaticConfig
Rename: HttpActionParams -> StaticConfig
diff --git a/Blog/Blog b/Blog/Blog
index 7fdb4d2..0da370e 100755
Binary files a/Blog/Blog and b/Blog/Blog differ
diff --git a/Framework/API.hs b/Framework/API.hs
index 0fb498d..438edc9 100644
--- a/Framework/API.hs
+++ b/Framework/API.hs
@@ -33,7 +33,7 @@ import Framework.Http.HTTPServer (serveHttp,serveStatic)
-- | Runtime controller action configuration
data ActionConfig = ActionConfig {
request :: Httpd.Request, -- ^ HTTP request
- httpParams :: HttpActionParams, -- ^ Static (global) configuration
+ httpParams :: StaticConfig, -- ^ Static (global) configuration
dbconnection :: Storage.DBConnection, -- ^ DB connection
sessionID :: Sessions.SessionID, -- ^ Current HTTP session ID
sessionMap :: Sessions.SessionMap, -- ^ Contains session variables
@@ -116,7 +116,7 @@ setcookie ac name value = Cookies.setcookie (cookiesExp ac) name value
-- * Main wrapper
-- | Main API wrapper. Connects to DB etc, then calls given function, then disconnects.
-withConfig :: HttpActionParams -- ^ Static (global) server configuration
+withConfig :: StaticConfig -- ^ Static (global) server configuration
-> Httpd.Request -- ^ HTTP request
-> (ActionConfig -> IO Httpd.Response) -- ^ Worker function
-> IO Httpd.Response
diff --git a/Framework/Http/HTTPServer.hs b/Framework/Http/HTTPServer.hs
index dc9ef00..7d4bb3b 100644
--- a/Framework/Http/HTTPServer.hs
+++ b/Framework/Http/HTTPServer.hs
@@ -51,7 +51,7 @@ serveStatic' (HP {docdir,hLog}) (Request {reqMethod}) resource =
choose "" = docdir++"/index.html"
choose x = docdir ++"/"++x
-httpWorker :: HttpActionParams -> URLConf -> Request -> IO Response
+httpWorker :: StaticConfig -> URLConf -> Request -> IO Response
httpWorker hap conf req@(Request {reqURI = URI {uriPath}}) = do
let s = unEscapeString $ reqBody req
-- putStrLn $ "Request body: "++show s
@@ -63,6 +63,6 @@ httpWorker hap conf req@(Request {reqURI = URI {uriPath}}) = do
defaultURLConf :: URLConf
defaultURLConf = Function serveStatic
-serveHttp :: Int -> HttpActionParams -> URLConf -> IO ()
+serveHttp :: Int -> StaticConfig -> URLConf -> IO ()
serveHttp port hap conf = initServer port (httpWorker hap conf)
diff --git a/Framework/Storage.hs b/Framework/Storage.hs
index f280164..fd8fbe2 100644
--- a/Framework/Storage.hs
+++ b/Framework/Storage.hs
@@ -28,8 +28,8 @@ connect :: String -- ^ DB backend
connect "sqlite3" file = DBC `fmap` (Sqlite3.connectSqlite3 file)
connect "psql" str = DBC `fmap` (PostgreSQL.connectPostgreSQL str)
--- | Connect to DB, get parameters from "HttpActionParams"
-connect' :: HttpActionParams -> IO DBConnection
+-- | Connect to DB, get parameters from "StaticConfig"
+connect' :: StaticConfig -> IO DBConnection
connect' (HP {dbDriver, dbPath}) = connect dbDriver dbPath
-- | Disconnect from DB
diff --git a/Framework/Types.hs b/Framework/Types.hs
index d26a9af..3ff4d52 100644
--- a/Framework/Types.hs
+++ b/Framework/Types.hs
@@ -15,7 +15,7 @@ type S = String
-------------------------------------------------------------------------------------------
-data HttpActionParams = HP {
+data StaticConfig = HP {
docdir :: String,
hLog :: Handle,
dbDriver :: String,
@@ -29,11 +29,11 @@ data HttpActionParams = HP {
class HttpValue v where
httpEmpty :: v -> Bool
- httpShow :: v -> S
+ httpShow :: v -> String
data HttpBox = forall a. HttpValue a => HB a
-instance HttpValue (Maybe S) where
+instance HttpValue (Maybe String) where
httpEmpty Nothing = True
httpEmpty (Just _) = False
@@ -51,7 +51,7 @@ instance HttpValue Int where
httpEmpty _ = False
httpShow = show
-instance HttpValue S where
+instance HttpValue String where
httpEmpty "" = True
httpEmpty _ = False
diff --git a/Framework/Urls.hs b/Framework/Urls.hs
index 11d701d..8769e2e 100644
--- a/Framework/Urls.hs
+++ b/Framework/Urls.hs
@@ -14,9 +14,9 @@ import Framework.Utils
import Framework.Types
type URLParts = [String]
-type StrAction = HttpActionParams -> Request -> String -> Maybe (IO Response)
-type ManyStrAction = HttpActionParams -> Request -> URLParts -> Maybe (IO Response)
-type HttpAction = HttpActionParams -> Request -> IO Response
+type StrAction = StaticConfig -> Request -> String -> Maybe (IO Response)
+type ManyStrAction = StaticConfig -> Request -> URLParts -> Maybe (IO Response)
+type HttpAction = StaticConfig -> Request -> IO Response
data URLConf = Action HttpAction
| OneOf URLConf URLConf
@@ -47,7 +47,7 @@ urlSplit uri = filter (/="") $ splitWith (=='/') url -- (url++slash)
urlJoin :: URLParts -> String
urlJoin us = concat $ intersperse "/" us
-runURLConf :: HttpActionParams -> Request -> String -> URLConf -> IO Response
+runURLConf :: StaticConfig -> Request -> String -> URLConf -> IO Response
runURLConf ps rq s conf = let murl = parseURIReference s
in case murl of
Nothing -> error "Couldn't parse URL!"
@@ -55,7 +55,7 @@ runURLConf ps rq s conf = let murl = parseURIReference s
Nothing -> return $ noSuchUrl True conf
Just act -> act
-runURLConf' :: URLConf -> URLParts -> HttpActionParams -> Request -> Maybe (IO Response)
+runURLConf' :: URLConf -> URLParts -> StaticConfig -> Request -> Maybe (IO Response)
-- runURLConf' _ [] _ = Nothing
runURLConf' (Prefix p conf) (x:xs) ps rq | p==x = runURLConf' conf xs ps rq
| otherwise = Nothing