summaryrefslogtreecommitdiff
path: root/fig-web/src/Fig/Web/Utils.hs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-06-16 05:42:58 -0400
committerLLLL Colonq <llll@colonq>2025-06-16 05:42:58 -0400
commita421eb9bdddfa7e2765456f756833d8941ac7a08 (patch)
treefb07429aff4bf970435c6465ffa56eb8eb54d28c /fig-web/src/Fig/Web/Utils.hs
parent7c3e41979478d6826f73a956a26c967aae1687a2 (diff)
fig-web: Initial puzzle site
Diffstat (limited to 'fig-web/src/Fig/Web/Utils.hs')
-rw-r--r--fig-web/src/Fig/Web/Utils.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/fig-web/src/Fig/Web/Utils.hs b/fig-web/src/Fig/Web/Utils.hs
index fbe17bf..521e781 100644
--- a/fig-web/src/Fig/Web/Utils.hs
+++ b/fig-web/src/Fig/Web/Utils.hs
@@ -11,13 +11,14 @@ module Fig.Web.Utils
, status
, queryParam, queryParamMaybe, formParam, formParamMaybe, pathParam
, header
- , respondText, respondJSON, respondHTML
+ , respondText, respondJSON, respondHTMLText, respondHTML, redirect
, WebsocketHandler
, websocket
, BusEventHandler, BusEventHandlers
, busEvents
, handleBusEvent
, subscribeBusEvents
+ , module Lucid.Html5
) where
import Fig.Prelude
@@ -38,6 +39,9 @@ import qualified Network.WebSockets as WS
import qualified Web.Scotty as Sc
+import qualified Lucid as L
+import Lucid.Html5
+
import qualified Toml
import Fig.Bus.Binary.Client
@@ -146,8 +150,14 @@ respondText = Sc.text . Text.L.fromStrict
respondJSON :: Aeson.ToJSON a => a -> Sc.ActionM ()
respondJSON = Sc.json
-respondHTML :: Text -> Sc.ActionM ()
-respondHTML = Sc.html . Text.L.fromStrict
+respondHTMLText :: Text -> Sc.ActionM ()
+respondHTMLText = Sc.html . Text.L.fromStrict
+
+respondHTML :: L.Html () -> Sc.ActionM ()
+respondHTML = Sc.html . L.renderText . html_
+
+redirect :: Text -> Sc.ActionM ()
+redirect = Sc.redirect . Text.L.fromStrict
type WebsocketHandler = (ByteString, WS.Connection -> IO ())
websocket :: [WebsocketHandler] -> Sc.ScottyM ()