From 0bffdaf882a9ecdae7887ac59223ed489c96dc64 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Sat, 3 Oct 2026 22:52:15 +0200 Subject: routing --- src/Main.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/Main.hs (limited to 'src/Main.hs') 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) -- cgit v1.3.1