From 19e71ff9504ca24c6484648eec2959153952fba3 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 10 May 2015 15:37:33 +0200 Subject: [PATCH] Directly create response --- src/Application.hs | 4 ++-- src/Views.hs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index 301f6c6..d6a4c77 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -34,7 +34,7 @@ app url' table = do middleware (serveStatic static) middleware logStdout - get "/" $ html (render index) + get "/" $ render index get var $ \name -> do url <- liftIO (extract table name) @@ -52,7 +52,7 @@ app url' table = do name <- liftIO (insert table url) logStr (printf "Registered %s -> %s " url name) let link = url' <> name - html (render $ done link) + render (done link) post "api" $ do url <- fmap unpack <$> param "url" diff --git a/src/Views.hs b/src/Views.hs index a3baae2..49e0e54 100644 --- a/src/Views.hs +++ b/src/Views.hs @@ -7,9 +7,10 @@ import Data.Text.Lazy (toStrict) import Text.Blaze.Html.Renderer.Text (renderHtml) import Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes as A +import qualified Web.Spock.Safe as S -render :: Html -> Text -render = toStrict . renderHtml +render :: Html -> S.ActionT IO () +render = S.html . toStrict . renderHtml done :: String -> Html done url = template $ do