diff options
Diffstat (limited to 'src/Main.hs')
| -rw-r--r-- | src/Main.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..20da414 --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE LambdaCase #-} + +import Network.CGI (runCGI, handleErrors, CGIResult, CGI, outputFPS) +import Text.Blaze.Html.Renderer.Utf8 (renderHtml) +import Settlr.Config (withConfig) +import Settlr.Routes (loadRoute, Route(..)) +import Settlr.Views.ErrorNotFound (viewErrorNotFound) +import Settlr.Views.Home (viewHome) + +cgiMain :: CGI CGIResult +cgiMain = withConfig $ do + view <- loadRoute >>= \case + Nothing -> viewErrorNotFound + Just RouteHome -> viewHome + Just RouteNew -> viewErrorNotFound + outputFPS (renderHtml view) + +main :: IO () +main = runCGI (handleErrors cgiMain) |
