module Happstack.Server.Hamlet
( hamletToResponse
)
where
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.Map as M
import Data.Text (Text)
import Text.Hamlet
import Happstack.Server
hamletToResponse :: (url -> [(Text, Text)] -> Text)
-> Hamlet url
-> Response
hamletToResponse showFn hamlet =
let msg = renderHamlet showFn hamlet
in toResponse_ (B.pack "text/html; charset=UTF-8") msg
toResponse_ :: B.ByteString -> L.ByteString -> Response
toResponse_ contentType message =
let res = Response 200 M.empty nullRsFlags message Nothing
in setHeaderBS (B.pack "Content-Type") contentType res