diff options
Diffstat (limited to 'fig-web/src/Fig/Web/Utils.hs')
| -rw-r--r-- | fig-web/src/Fig/Web/Utils.hs | 16 |
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 () |
