diff options
| author | Hannes Schulze <contact@haschu.me> | 2026-10-04 03:38:43 +0200 |
|---|---|---|
| committer | Hannes Schulze <contact@haschu.me> | 2026-10-04 03:38:43 +0200 |
| commit | 38cb6b48653f950092e6cd6cd2332eec3f77e667 (patch) | |
| tree | a7b6286f01c166ed7f25cd06d53f6811c5022a6a /src/Main.hs | |
| parent | 41dc555f3a4d53a8773a03ac24bed9aea8143bfa (diff) | |
persistence api
Diffstat (limited to 'src/Main.hs')
| -rw-r--r-- | src/Main.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Main.hs b/src/Main.hs index 9fda84b..9f58327 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -3,18 +3,22 @@ import Network.CGI (runCGI, handleErrors, outputFPS, setHeader) import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -import Settlr.Config (withConfig, ScriptM) +import Settlr.Config (loadConfig) +import Settlr.Scripts (ScriptM, runScript) import Settlr.Routes (loadRoute, Route(..)) import Settlr.Views.ErrorNotFound (viewErrorNotFound) import Settlr.Views.Home (viewHome) import Text.Blaze.Html5 (Html) +import Network.CGI.Protocol (CGIResult) -view :: Maybe Route -> ScriptM Html -view (Just RouteHome) = viewHome -view (Just RouteNew) = viewErrorNotFound -view Nothing = viewErrorNotFound +run :: Maybe Route -> ScriptM Html +run (Just RouteHome) = viewHome +run (Just RouteNew) = viewErrorNotFound +run Nothing = viewErrorNotFound + +script :: ScriptM CGIResult +script = do setHeader "Content-type" "text/html; charset=\"utf-8\"" + loadRoute >>= run >>= outputFPS . renderHtml main :: IO () -main = runCGI $ handleErrors $ withConfig $ do - setHeader "Content-type" "text/html; charset=\"utf-8\"" - loadRoute >>= view >>= outputFPS . renderHtml +main = runCGI $ handleErrors $ (loadConfig >>= runScript script) |
