diff options
| author | Hannes Schulze <contact@haschu.me> | 2026-10-03 22:52:15 +0200 |
|---|---|---|
| committer | Hannes Schulze <contact@haschu.me> | 2026-10-03 22:52:15 +0200 |
| commit | 0bffdaf882a9ecdae7887ac59223ed489c96dc64 (patch) | |
| tree | 53c9393820018f55c76fbf54aa56803dbeb65ab7 /src/Main.hs | |
| parent | 0d43caf82404abc610a56520bfe7ef15559ce2c5 (diff) | |
routing
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) |
