From abbf64f5a5453fcb6bfe9b90df9e8f6fa002b66a Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Sun, 5 Mar 2023 14:28:47 +0400 Subject: Fixed warnings --- app/Web/Response.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/Web/Response.hs') 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 "404 Not Found") +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 -- cgit v1.2.3