diff options
Diffstat (limited to 'app/Web/Response.hs')
| -rw-r--r-- | app/Web/Response.hs | 8 |
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 |