summaryrefslogtreecommitdiff
path: root/Response.hs
blob: be347c104c8a1fd38f88119ed6d34588028cc1ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Response where

data Response
  = HtmlResponse Int String -- Код возврата, содержимое HTML
  | TextResponse Int String String -- Код возврата, Content-Type, содержимое HTML
  deriving Show

notFoundResponse = HtmlResponse 404 "<strong>404 Not Found</strong>"

getStatusCode (HtmlResponse code _) = code
getStatusCode (TextResponse code _ _) = code

getContentType (HtmlResponse _ _) = "text/html"
getContentType (TextResponse _ contentType _) = contentType

getContent (HtmlResponse _ content) = content
getContent (TextResponse _ _ content) = content