summaryrefslogtreecommitdiff
path: root/app/Web/Response.hs
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2023-03-05 14:28:47 +0400
committerAndrew Guschin <guschin.drew@gmail.com>2023-03-05 14:28:47 +0400
commitabbf64f5a5453fcb6bfe9b90df9e8f6fa002b66a (patch)
tree9e567245de098d9938b97a96b5e20bfa2ebe2543 /app/Web/Response.hs
parenta0e8e5a91d15ed8c79f4a1b5914d3a6242c0cbd3 (diff)
Fixed warningsHEADmaster
Diffstat (limited to 'app/Web/Response.hs')
-rw-r--r--app/Web/Response.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/Web/Response.hs b/app/Web/Response.hs
index 3c393ad..11ab5f2 100644
--- a/app/Web/Response.hs
+++ b/app/Web/Response.hs
@@ -10,21 +10,27 @@ data Response
| TextResponse Int Text Text -- Код возврата, Content-Type, содержимое HTML
deriving Show
+notFoundResponse :: Response
notFoundResponse = HtmlResponse 404 (T.pack "<strong>404 Not Found</strong>")
+getStatusCode :: Response -> Int
getStatusCode (HtmlResponse code _) = code
getStatusCode (TextResponse code _ _) = code
+getContentType :: Response -> Text
getContentType (HtmlResponse _ _) = (T.pack "text/html")
getContentType (TextResponse _ contentType _) = contentType
+getContent :: Response -> Text
getContent (HtmlResponse _ content) = content
getContent (TextResponse _ _ content) = content
formResponse :: Response -> Text
-formResponse (HtmlResponse code html) =
+formResponse (HtmlResponse code html) =
T.strip $ T.unlines
$ map T.pack [ "HTTP/1.1 " ++ getStatus code
, "Content-Type: text/html; charset=utf-8"
, "Connection: close"
, "" ] ++ [html]
+-- TODO: Добавить обработчик
+formResponse _ = undefined