-- | -- Module : Network.Wai.Responsible -- Description : Typeclass for respons -- Copyright : 2014, Peter Harpending. -- License : BSD3 -- Maintainer : Peter Harpending -- Stability : experimental -- Portability : archlinux -- module Network.Wai.Responsible where import qualified Data.ByteString as Bs import qualified Data.ByteString.Lazy as Bl import Network.Wai import Network.HTTP.Types -- |Things that generate a response class Responsible a where respond :: a -> Request -> Response -- |Things that generate a response, but need IO to do so class Irresponsible a where respondIO :: a -> Request -> IO Response -- |Given a content type, such as @"text/html"@, and a 'Bl.Bytestring' -- response, send a response with status 200. respond200 :: Bs.ByteString -> Bl.ByteString -> Response respond200 contentType = responseLBS status200 [(hContentType, contentType)] -- |Given a content type, such as @"text/html"@, and a 'Bl.Bytestring' -- response, send a response with status 403. respond403 :: Bs.ByteString -> Bl.ByteString -> Response respond403 contentType = responseLBS status403 [(hContentType, contentType)] -- |Given a content type, such as @"text/html"@, and a 'Bl.Bytestring' -- response, send a response with status 404. respond404 :: Bs.ByteString -> Bl.ByteString -> Response respond404 contentType = responseLBS status404 [(hContentType, contentType)] -- |Given a content type, such as @"text/html"@, and a 'Bl.Bytestring' -- response, send a response with status 405. respond405 :: Bs.ByteString -> Bl.ByteString -> Response respond405 contentType = responseLBS status405 [(hContentType, contentType)] -- |Error pages, data ErrorPage = Status403 | Status404 | Status405