From 7addd8982f1aca5c81eb5d18158defcf32593ce3 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 28 Oct 2021 19:31:28 -0400 Subject: [PATCH] implemented GemResponse type and constructor --- src/Network/GemServ/Types.hs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Network/GemServ/Types.hs b/src/Network/GemServ/Types.hs index d94c274..b4179f4 100644 --- a/src/Network/GemServ/Types.hs +++ b/src/Network/GemServ/Types.hs @@ -28,12 +28,15 @@ module Network.GemServ.Types ( -- * Types GemURL (..), GemRequest (..), + GemResponse (..), -- * Constructors newGemURL, - newGemRequest + newGemRequest, + newGemResponse, ) where -import Data.Word (Word32) +import qualified Data.ByteString as BS +import Data.Word (Word8, Word32) import Data.X509 (Certificate) -- | Gemini URL @@ -56,6 +59,16 @@ data GemRequest = GemRequest -- ^ The client certificate (if available) } deriving (Eq, Show) +-- | Describes a response to a Gemini request +data GemResponse = GemResponse + { respStatus :: Word8 + -- ^ The response status code + , respMeta :: String + -- ^ The response metadata + , respBody :: Maybe BS.ByteString + -- ^ The response body + } deriving (Eq, Show) + -- | Builds a new 'GemURL' newGemURL :: String @@ -78,4 +91,12 @@ newGemRequest url = GemRequest , reqCert = Nothing } +-- | Builds a 'GemResponse' +newGemResponse :: GemResponse +newGemResponse = GemResponse + { respStatus = 20 + , respMeta = "text/gemini" + , respBody = Nothing + } + --jl