diff options
| author | Andrew <saintruler@gmail.com> | 2020-11-27 18:49:06 +0400 |
|---|---|---|
| committer | Andrew <saintruler@gmail.com> | 2020-11-27 18:49:06 +0400 |
| commit | 0093cbc556c735d148b571011a45ad32c567d62d (patch) | |
| tree | d9109daa448565b902f199d6193976998a252529 /Web/Response.hs | |
| parent | 463665e8a91e8b0611c3e8413842182c67d3ea3d (diff) | |
Added feature of forming reponse into text
Diffstat (limited to 'Web/Response.hs')
| -rw-r--r-- | Web/Response.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Web/Response.hs b/Web/Response.hs index 39f6887..9bc2179 100644 --- a/Web/Response.hs +++ b/Web/Response.hs @@ -3,6 +3,8 @@ module Web.Response where import qualified Data.Text as T import Data.Text (Text) +import Web.Utils + data Response = HtmlResponse Int Text -- Код возврата, содержимое HTML | TextResponse Int Text Text -- Код возврата, Content-Type, содержимое HTML @@ -18,3 +20,11 @@ getContentType (TextResponse _ contentType _) = contentType getContent (HtmlResponse _ content) = content getContent (TextResponse _ _ content) = content + +formResponse :: Response -> Text +formResponse (HtmlResponse code html) = + T.unlines + $ map T.pack [ "HTTP/1.1 " ++ getStatus code + , "Content-Type: text/html; charset=utf-8" + , "Connection: keep-alive" + , "" ] ++ [html] |